preserves/tests/samples.txt

327 lines
16 KiB
Plaintext

@<EmacsMode "-*- preserves -*-">
@<Documentation [
"Individual test cases may be any of the following record types:"
<TestCaseTypes {
Test: {fields: [binary annotatedValue] expectations: {1 2 3 4 5 6 7 8 9 11}}
NondeterministicTest: {fields: [binary annotatedValue] expectations: {1 2 3 4 5 6 7 8 10 11}}
StreamingTest: {fields: [binary annotatedValue] expectations: {1 2 3 4 5 6 7 8 9 }}
DecodeTest: {fields: [binary annotatedValue] expectations: {1 2 3 4 5 6 7 8}}
ParseError: {fields: [text] expectations: {12}}
ParseShort: {fields: [text] expectations: {13}}
DecodeError: {fields: [bytes] expectations: {14}}
DecodeShort: {fields: [bytes] expectations: {15}}
}>
"In each test, let value = strip(annotatedValue),",
" forward = value,",
" back = value,"
"except where test-case-specific values of `forward` and/or `back` are provided"
"by the executing harness (of particular importance for `StreamingTest`s),"
"and check the following numbered expectations according to the table above:"
<TestCaseExpectations {
1: "value = back"
2: "strip(decodeBinary(encodeBinary(value))) = back"
3: "strip(decodeBinary(encodeBinary(forward))) = back"
4: "strip(decodeBinary(binary)) = back"
5: "decodeBinary(binary) = annotatedValue"
6: "decodeBinary(encodeBinary(annotatedValue)) = annotatedValue"
7: "decodeText(encodeText(value)) = back"
8: "decodeText(encodeText(forward)) = back"
9: "encodeBinary(forward) = binary"
10: "canonicallyEncodeBinary(forward) = binary"
11: "encodeBinary(annotatedValue) = binary"
12: "decodeText(text) fails with a syntax error (NB. never with premature EOF)"
13: "decodeText(text) fails signalling premature EOF (NB. never with a syntax error)"
14: "decodeBinary(bytes) fails with a syntax error (NB. never with premature EOF)"
15: "decodeBinary(bytes) fails signalling premature EOF (NB. never with a syntax error)"
}>
"Each `StreamingTest` will need to have an implementation-specific `forward`"
"supplied that encodes to the specific format C byte sequences in `binary`."
"Alternatively, implementations may choose to skip expectation 11 for"
"`StreamingTest`s, treating them like `DecodeTest`s."
]>
<TestCases
<ExpectedPlaceholderMapping {
0: discard
1: capture
2: observe
}>
{
annotation1: <Test #hex{055361626339} @"abc" 9>
annotation2: <Test #hex{05536162630553646566929005517890} @"abc" @"def" [[] @"x" []]>
annotation3: <Test #hex{050531320505333435} @@1 2 @@3 4 5>
annotation4: <NondeterministicTest #hex{b4 05 72616b 7161 05 726176 31 05 72626b 7162 05 726276 32}
{@ak a: @av 1 @bk b: @bv 2}>
annotation5: <Test #hex{05726172827152057261667166} @ar <R @af f>>
annotation6: <Test #hex{82057261727152057261667166} <@ar R @af f>>
annotation7:
@"Stop reading symbols at @ -- this test has three separate annotations"
<Test #hex{05716105716205716390} @a@b@c[]>
bytes1: <StreamingTest #hex{26626865626c6c616f04} #"hello">
bytes2: <Test #hex{6568656c6c6f} #"hello">
bytes2a: <Test @"Internal whitespace is allowed, including commas!" #hex{65, 68, 65, 6c, 6c, 6f} #"hello">
bytes3: <Test #hex{63414243} #"ABC">
bytes4: <Test #hex{63414243} #hex{414243}>
bytes5: <Test #hex{63414a4e} #hex{ 41 4A 4e }>
bytes6: @"Bytes must be 2-digits entire" <ParseError "#hex{414 243}">
bytes7: <Test #"\x66corymb" #base64{Y29yeW1i}>
bytes8: <Test #"\x66corymb" #base64{Y29 yeW 1i}>
bytes9: <Test #"\x62Hi" #base64{SGk=}>
bytes10: <Test #"\x62Hi" #base64{SGk}>
bytes11: <Test #"\x62Hi" #base64{S G k}>
bytes12: @"Bytes syntax only supports \\x, not \\u" <ParseError "#\"\\u6c34\"">
bytes13: <Test #hex{6f 11 61 62 63 6c 34 f0 5c 2f 22 08 0c 0a 0d 09 78 79 7a} #"abc\x6c\x34\xf0\\/\"\b\f\n\r\txyz">
dict0: <Test #hex{b0} {}>
dict1: <NondeterministicTest #hex{b8 5162 01 7161 31 93313233 6163 b2 7a66697273742d6e616d65 59456c697a6162657468 b2 777375726e616d65 59426c61636b77656c6c} { a: 1 "b": #true [1 2 3]: #"c" { first-name: "Elizabeth" }: { surname: "Blackwell" } }>
dict2: @"Missing close brace" <ParseShort "{ a: b, c: d ">
dict2a: @"Missing close brace" <ParseShort "{">
dict3: @"Duplicate key" <ParseError "{ a: 1, a: 2 }">
dict4: @"Unexpected close brace" <ParseError "}">
dict5: @"Missing value" <DecodeError #hex{b3 31 32 33}>
double1: <Test #hex{033ff0000000000000} 1.0>
double2: <Test #hex{03fe3cb7b759bf0426} -1.202e300>
float1: <Test #hex{023f800000} 1.0f>
int-257: <Test #hex{42feff} -257>
int-256: <Test #hex{42ff00} -256>
int-255: <Test #hex{42ff01} -255>
int-254: <Test #hex{42ff02} -254>
int-129: <Test #hex{42ff7f} -129>
int-128: <Test #hex{4180} -128>
int-127: <Test #hex{4181} -127>
int-4: <Test #hex{41fc} -4>
int-3: <Test #hex{3d} -3>
int-2: <Test #hex{3e} -2>
int-1: <Test #hex{3f} -1>
int0: <Test #hex{30} 0>
int1: <Test #hex{31} 1>
int12: <Test #hex{3c} 12>
int13: <Test #hex{410d} 13>
int127: <Test #hex{417f} 127>
int128: <Test #hex{420080} 128>
int255: <Test #hex{4200ff} 255>
int256: <Test #hex{420100} 256>
int32767: <Test #hex{427fff} 32767>
int32768: <Test #hex{43008000} 32768>
int65535: <Test #hex{4300ffff} 65535>
int65536: <Test #hex{43010000} 65536>
int131072: <Test #hex{43020000} 131072>
list0: <Test #hex{90} []>
list1: <StreamingTest #hex{293132333404} [1 2 3 4]>
list2: <StreamingTest #hex{2925636162630425636465660404} ["abc" "def"]>
list3: <StreamingTest #hex{2992516131925162329251633304} [["a" 1] ["b" 2] ["c" 3]]>
list4: <Test #hex{9431323334} [1 2 3 4]>
list4a: <Test #hex{9431323334} [1, 2, 3, 4]>
list5: <Test #hex{943e3f3031} [-2 -1 0 1]>
list6: <Test #hex{97 5568656c6c6f 757468657265 65776f726c64 90 a0 01 00} ["hello" there #"world" [] #set{} #true #false]>
list7: <Test #hex{93 73616263 732e2e2e 73646566} [abc ... def]>
list8: @"Missing close bracket" <ParseShort "[">
list9: @"Unexpected close bracket" <ParseError "]">
noop0: <DecodeTest #hex{ff10} discard>
noop1: <DecodeTest #hex{ff31} 1>
noop2: <DecodeTest #hex{ffffff42ff00} -256>
noop3: <DecodeTest #hex{ff05ff53616263ff42ff00} @"abc" -256>
noop4: @"No-ops must be followed by something" <DecodeShort #hex{ffffff}>
noop5: @"No input at all is considered short" <DecodeShort #hex{}>
placeholder0: <Test #hex{10} discard>
placeholder1: <Test #hex{11} capture>
placeholder2: <Test #hex{12} observe>
record1: <Test #hex{82118110} <capture <discard>>>
record2: <Test #hex{82 12 83 75737065616b 81 10 82 11 81 10} <observe <speak <discard>, <capture <discard>>>>>
record3: <Test #hex{85 95 767469746c6564 76706572736f6e 32 757468696e67 31 4165 59426c61636b77656c6c 84 7464617465 42071d 32 33 524472} <[titled person 2 thing 1] 101 "Blackwell" <date 1821 2 3> "Dr">>
record4: <Test #hex{8110} <discard>>
record5: <Test #hex{823790} <7[]>>
record6: <Test #hex{8210787375727072697365} <discard surprise>>
record7: <Test #hex{835761537472696e673334} <"aString" 3 4>>
record8: <Test #hex{8381103334} <<discard> 3 4>>
record9: @"Missing record label" <ParseError "<>">
record10: @"Missing close-angle-bracket" <ParseShort "<">
record11: @"Unexpected close-angle-bracket" <ParseError ">">
set0: <Test #hex{a0} #set{}>
set1: <NondeterministicTest #hex{a3313233} {1 2 3}>
set1a: <NondeterministicTest #hex{a3313233} #set{1 2 3}>
set2: @"Missing close brace" <ParseShort "#set{ 1 2 3 ">
set2a: @"Missing close brace" <ParseShort "#set{">
set3: @"Duplicate value" <ParseError "#set{a a}">
stream1: @"Chunk must be bytes" <DecodeError #hex{25516104}>
stream2: @"Chunk must be bytes" <DecodeError #hex{25716104}>
stream3: @"Chunk must be bytes" <DecodeError #hex{26516104}>
stream4: @"Chunk must be bytes" <DecodeError #hex{26716104}>
stream5: @"Chunk must be bytes" <DecodeError #hex{27516104}>
stream6: @"Chunk must be bytes" <DecodeError #hex{27716104}>
stream7: @"Missing end byte" <DecodeShort #hex{290000}>
stream8: @"Missing element" <DecodeShort #hex{930000}>
stream9: @"Unexpected end stream byte" <DecodeError #hex{04}>
string0: <Test #hex{50} "">
string0a: <StreamingTest #hex{2504} "">
string1: <StreamingTest #hex{25626865626c6c616f04} "hello">
string2: <StreamingTest #hex{25626865636c6c6f04} "hello">
string3: <Test #hex{5568656c6c6f} "hello">
string4: <Test #hex{5f 14 616263e6b0b4e6b0b45c2f22080c0a0d0978797a} "abc\u6c34\u6C34\\/\"\b\f\n\r\txyz">
string5: <Test #hex{54f09d849e} "\uD834\uDD1E">
symbol0: <Test #hex{70} ||>
symbol1: <StreamingTest #hex{27626865626c6c616f04} hello>
symbol2: <Test #hex{7568656c6c6f} hello>
whitespace0: @"Leading spaces have to eventually yield something" <ParseShort " ">
whitespace1: @"No input at all is considered short" <ParseShort "">
value1: <Test #"\x66corymb" #value#"fcorymb">
value2: <Test #"\x01" #value#"\x01">
value3: <Test #"\x01" #value#base64{AQ}>
value4: <Test #"\x01" #value#base64{AQ==}>
value5: <Test #"\x01" #value #base64{AQ==}>
value6: <Test #hex{93313233} #value#hex{93313233}>
longlist14: <Test #hex{9e0000000000000000000000000000}
[#false #false #false #false #false
#false #false #false #false #false
#false #false #false #false]>
longlist15: <Test #hex{9f0f000000000000000000000000000000}
[#false #false #false #false #false
#false #false #false #false #false
#false #false #false #false #false]>
longlist100:
<Test #hex{9f64
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000}
[#false #false #false #false #false #false #false #false #false #false
#false #false #false #false #false #false #false #false #false #false
#false #false #false #false #false #false #false #false #false #false
#false #false #false #false #false #false #false #false #false #false
#false #false #false #false #false #false #false #false #false #false
#false #false #false #false #false #false #false #false #false #false
#false #false #false #false #false #false #false #false #false #false
#false #false #false #false #false #false #false #false #false #false
#false #false #false #false #false #false #false #false #false #false
#false #false #false #false #false #false #false #false #false #false]>
longlist200:
<Test #hex{9fc801
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000}
[#false #false #false #false #false #false #false #false #false #false
#false #false #false #false #false #false #false #false #false #false
#false #false #false #false #false #false #false #false #false #false
#false #false #false #false #false #false #false #false #false #false
#false #false #false #false #false #false #false #false #false #false
#false #false #false #false #false #false #false #false #false #false
#false #false #false #false #false #false #false #false #false #false
#false #false #false #false #false #false #false #false #false #false
#false #false #false #false #false #false #false #false #false #false
#false #false #false #false #false #false #false #false #false #false
#false #false #false #false #false #false #false #false #false #false
#false #false #false #false #false #false #false #false #false #false
#false #false #false #false #false #false #false #false #false #false
#false #false #false #false #false #false #false #false #false #false
#false #false #false #false #false #false #false #false #false #false
#false #false #false #false #false #false #false #false #false #false
#false #false #false #false #false #false #false #false #false #false
#false #false #false #false #false #false #false #false #false #false
#false #false #false #false #false #false #false #false #false #false
#false #false #false #false #false #false #false #false #false #false]>
rfc8259-example1: <NondeterministicTest
#hex{b2 55 496d616765
bc 58 416e696d61746564
75 66616c7365
56 486569676874
42 0258
53 494473
94 41 74
42 03af
42 00ea
43 009789
59 5468756d626e61696c
b6 56 486569676874
41 7d
53 55726c
5f26 687474703a2f2f7777772e6578616d706c652e636f6d2f696d6167652f343831393839393433
55 5769647468
41 64
55 5469746c65
5f14 566965772066726f6d203135746820466c6f6f72
55 5769647468
42 0320}
{
"Image": {
"Width": 800,
"Height": 600,
"Title": "View from 15th Floor",
"Thumbnail": {
"Url": "http://www.example.com/image/481989943",
"Height": 125,
"Width": 100
},
"Animated" : false,
"IDs": [116, 943, 234, 38793]
}
}>
rfc8259-example2: <NondeterministicTest
#hex{92 bf10 57 41646472657373 50
54 43697479 5d 53414e204652414e434953434f
57 436f756e747279 52 5553
58 4c61746974756465 03 4042e226809d4952
59 4c6f6e676974756465 03 c05e99566cf41f21
55 5374617465 52 4341
53 5a6970 55 3934313037
59 707265636973696f6e 53 7a6970
bf10 57 41646472657373 50
54 43697479 59 53554e4e5956414c45
57 436f756e747279 52 5553
58 4c61746974756465 03 4042af9d66adb403
59 4c6f6e676974756465 03 c05e81aa4fca42af
55 5374617465 52 4341
53 5a6970 55 3934303835
59 707265636973696f6e 53 7a6970}
[
{
"precision": "zip",
"Latitude": 37.7668,
"Longitude": -122.3959,
"Address": "",
"City": "SAN FRANCISCO",
"State": "CA",
"Zip": "94107",
"Country": "US"
},
{
"precision": "zip",
"Latitude": 37.371991,
"Longitude": -122.026020,
"Address": "",
"City": "SUNNYVALE",
"State": "CA",
"Zip": "94085",
"Country": "US"
}
]>
}
>