Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tests are groups of three lines: program, input, expected output
- # Blank lines and lines starting with # are ignored
- #
- # Simple value tests to check parser. Input is irrelevant
- #
- .
- null
- null
- #
- # Double number test
- #
- .
- 12.014
- 12.014
- #
- # Double scientific notation no sign
- #
- .
- 1e10
- 1.0e10
- #
- # Double scientific notation + no sign (default +1)
- #
- .
- 23.5E1
- 235.0
- #
- # Double scientific notation + sign larger
- #
- .
- 23.5E+12
- 2.35E+13
- #
- # Double scientific notation - sign
- #
- .
- 1E-13
- 1.0E-13
- #
- # Integer number test
- #
- .
- 123
- 123
- #
- # String test basic
- #
- .
- "test string"
- "test string"
- #
- # String test escape chars
- #
- .
- "\"Hello World\""
- "\"Hello World\""
- #
- # String test number
- #
- .
- "123"
- "123"
- #
- # Test floats
- #
- .
- 0.5
- 0.5
- #
- # Tests w/ negative floats
- #
- .
- -1.5
- -1.5
- # Test w/ arrays (basic)
- #
- .
- [1,2,3]
- [1,2,3]
- # Test w/ empty array
- #
- .
- []
- []
- # Test w/ arrays + spaces
- #
- .
- [1, 2 ,3]
- [1,2,3]
- # Test w/ arrays w/ multiple types of elements
- #
- .
- [1, -1.5 ,"abc"]
- [1,-1.5,"abc"]
- # Test w/ spaces before arrays
- #
- .
- [1, -1.5 ,"abc"]
- [1,-1.5,"abc"]
- # Test JObject basic (1 el)
- #
- #
- .
- {"a":1}
- {"a":1}
- # Test JObject basic (>1 diff elements) + spaces
- #
- #
- .
- {"a":1, "b": 2, "c": "abc"}
- {"a":1,"b":2,"c":"abc"}
- # Test JObject basic empty arr
- #
- #
- .
- {}
- {}
- # Test JObject with Object with JArray
- #
- #
- .
- {"a":1, "b": 2, "c": [1, 2, 3]}
- {"a":1,"b":2,"c":[1,2,3]}
- #
- # String test control char
- #
- .
- "\u2600"
- "\"\9728\"\n"
- #
- # Test weird string
- #
- .
- "Aa\r\n\t\b\f"
- "\"Aa\\r\\n\\t\\b\\f\"\n"
- #
- # True test
- #
- .
- true
- true
- #
- # False test
- #
- .
- false
- false
- #
- # Field access, piping
- #
- .foo
- {"foo": 42, "bar": 43}
- 42
- .foo | .bar
- {"foo": {"bar": 42}, "bar": "badvalue"}
- 42
- .foo.bar
- {"foo": {"bar": 42}, "bar": "badvalue"}
- 42
- .foo_bar
- {"foo_bar": 2}
- 2
- .["foo"].bar
- {"foo": {"bar": 42}, "bar": "badvalue"}
- 42
- ."foo"."bar"
- {"foo": {"bar": 20}}
- 20
- # Arrays
- [.[]|.foo?]
- [1,[2],{"foo":3,"bar":4},{},{"foo":5}]
- [3,null,5]
- [.[]|.foo?.bar?]
- [1,[2],[],{"foo":3},{"foo":{"bar":4}},{}]
- [4,null]
- [.[]|.[]?]
- [1,null,[],[1,[2,[[3]]]],[{}],[{"a":[1,[2]]}]]
- [1,[2,[[3]]],{},{"a":[1,[2]]}]
- [.[]|.[1:3]?]
- [1,null,true,false,"abcdef",{},{"a":1,"b":2},[],[1,2,3,4,5],[1,2]]
- [null,"bc",[],[2,3],[2]]
- # Value construction
- true
- null
- true
- false
- null
- false
- null
- 42
- null
- 1
- null
- 1
- -1
- null
- -1
- {}
- null
- {}
- []
- null
- []
- {x: -1}
- null
- {"x": -1}
- #
- # Dictionary construction syntax
- #
- {a: 1}
- null
- {"a":1}
- {a,b,(.d):.a,e:.b}
- {"a":1, "b":2, "c":3, "d":"c"}
- {"a":1, "b":2, "c":1, "e":2}
- {"a",b,"a$2"}
- {"a":1, "b":2, "c":3, "a$2":4}
- {"a":1, "b":2, "a$2":4}
- #
- # Unicode input
- #
- # unicode tests are particularly finicky depending on the encoding/OS/terminal
- # if the grading tests say you're deadling with unicode just fine
- # then you can safely ignore the tests below
- # but if you are missing points during grading these might help to debug your project
- .
- "\b\r\f\t\n\r\u02ac\u058E\u05d2\u0606"
- "\b\r\f\t\n\rʬ֎ג؆"
- .
- "\u0000"
- "\u0000"
- #
- # Null input
- #
- .[0:10]
- null
- null
- .[0:10]?
- null
- null
- .[0]
- null
- null
- .[0]?
- null
- null
- .["foo"]
- null
- null
- .["foo"]?
- null
- null
- .foo
- null
- null
- .foo?
- null
- null
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement