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
- #
- # 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"
- "\u2600"
- #
- # Test weird string
- #
- .
- "Aa\r\n\t\b\f"
- "Aa\r\n\t\b\f"
- #
- # True test
- #
- .
- true
- true
- #
- # False test
- #
- .
- false
- false
- ### FILTERS
- #
- # Filter paranthesis basic case (identity) + spaces (to check token)
- #
- ( . )
- "abc"
- "abc"
- #
- # Field access (ObjIndex) which exists
- #
- .foo
- {"foo": 42, "bar": 43}
- 42
- #
- # Field access (ObjIndex) which exists AND is a string ."foo", but not generic
- #
- ."foo"
- {"foo": 42, "bar": 43}
- 42
- #
- # Field access (ObjIndex) which DOES NOT exist
- #
- .mama
- {"foo": 42, "bar": 43}
- null
- #
- # ObjIndex generic (ObjValueIt w/ 1 element) -> .["foo"]
- #
- .["foo"]
- {"bar": 43, "foo": 42}
- 42
- #
- # ObjIndex generic with spaces (ObjValueIt w/ 1 element) -> .["foo bar"]
- #
- .["foo bar"]
- {"foo bar": 43, "foo": 42}
- 43
- #
- # Field access generic (ObjValueIt) which DOES NOT exist
- #
- .["mama"]
- {"foo": 42, "bar": 43}
- null
- #
- # Object Value Iterator w/ multiple elements, some exist, some don't
- #
- .["abc", "f1", "no"]
- {"f1" : "hi", "yes" : null, "abc" : [1,2, 3]}
- [1,2,3]
- "hi"
- null
- #
- # ArrIt through all elements in Array
- #
- .[]
- [0, 1,2,3,4]
- 0
- 1
- 2
- 3
- 4
- #
- # ObjValueIt through all elements in JObject
- #
- .[-2, -3]
- [0, 1,2,3,4]
- 3
- 2
- #
- # ArrIt negative values
- #
- .[-3, -2]
- [1, 2, 3]
- 1
- 2
- #
- # ArrIt negative len < 0; -len > length xs should not wrap around -> null
- #
- .[-100]
- [1, 2, 3]
- null
- #
- # ArrIt negative len > 0; len > length xs should not wrap around -> null
- #
- .[100]
- [1, 2, 3]
- null
- #Tests taken from week4 impl by me and retested here
- #
- # ObjIndex on JNull input
- #
- .["a"]
- null
- null
- #
- # ObjIndex all missing
- #
- .["a", "b"]
- {"c":1, "d":2}
- null
- null
- #
- # ObjIndex one exists
- #
- .["a", "c"]
- {"a": 1, "b": "f"}
- 1
- null
- #
- # ObjIndex one exists other order
- #
- .["c", "a"]
- {"a": 1, "b": "f"}
- null
- 1
- #
- # ArrIndex test (in bounds)
- #
- .[2]
- [0, 1, "abc",3]
- "abc"
- #
- # ArrIt w/ multiple indexes, some in bounds, some out of boundsj
- #
- .[1, 2, 4 ]
- [0, 1, 2,3]
- 1
- 2
- null
- #
- # ArrIndexSlice both there in bounds
- #
- .[0:2]
- [1,2,3,4]
- [1,2]
- #
- # ArrIndexSlice emtpy range
- #
- .[2:2]
- [1,2,3,4]
- []
- #
- # ArrIndexSlice only left given
- #
- .[2:]
- [1,2,3,4]
- [3,4]
- #
- # ArrIndexSlice only right given
- #
- .[:3]
- [1,2,3,4]
- [1,2,3]
- #
- # ArrIndexSlice left >= right
- #
- .[4:2]
- [1,2,3,4,5,6]
- []
- #
- # ArrIndex negative (last but not least el : -2)
- #
- .[-2]
- [1,2,3,4,5,6]
- 5
- .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
- #
- # ObjIndex & ArrIndex combined -> Value Constructor, TODO
- #
- .foo[2]
- {"foo" : [1, 2, 3]}
- 3
- #
- # Comma and Pipe ambiguous, Comma should have priority
- #
- .a, .b, .c | .foo
- {"a" : {"foo" : 1}, "b" : {"foo" : 2}, "c" : {"foo" : 3}}
- 1
- 2
- 3
- #
- # Comma and Pipe + parnthesis, Comma should have priority
- #
- .a,.b,(.c|.bar)|.foo
- {"a" : {"foo" : 1}, "b" : {"foo" : 2}, "c" : {"foo" : 3, "bar" : {"foo" : 100}}}
- 1
- 2
- 100
- #
- # Paranthesis nested test
- #
- ((.))
- false
- false
- #
- # Paranthesis nested - Pipe and Comma inversion of priority
- #
- .a , (.b | .foo )
- {"a" : true, "b" : {"foo" : "lol" } }
- true
- "lol"
- #
- # Test parenthesis a -> b pipe
- #
- (.a| .b )
- {"a" : {"b" : {"foo" : "lol" }} }
- {"foo":"lol"}
- # VALUE CONSTRUCTORS
- # 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}
- #
- # Dictionary construction when it exists
- #
- {a : 1}
- {"a":2}
- {"a":1}
- #
- # Dictionary construction when it exists
- #
- {a}
- {"a":1}
- {"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}
- {a}
- {"a":1}
- {"a":1}
- {e:.b}
- {"a":1, "b":2, "c":3, "d":"c"}
- {"e:2}
- {e:100}
- {"a":1, "b":2, "c":3, "d":"c"}
- {"e":100}
- {(.d):2}
- {"a":1, "b":2, "c":3, "d":"c"}
- {"c":2}
- {(.d):.a}
- {"a":1, "b":2, "c":3, "d":"c"}
- {"c":1}
- {a,b,(.d):.a}
- {"a":1, "b":2, "c":3, "d":"c"}
- {"a":1, "b":2, "c":1}
- {e:.b}
- {"a":1, "b":2, "c":3, "d":"c"}
- {"e": 2}
- #
- # Test assignment 1 - Value ctor
- #
- {"this" : [.]}
- 1
- {"this": [1]}
- #
- # Test assignment 2 - Value ctor
- #
- {"this" : [42]}
- null
- {"this": [42]}
- #
- # 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
- #
- # Test string slice
- #
- .[1:3]
- "abcdef"
- "bc"
- #
- # Test string slice
- #
- .[1:3]
- "abcdef"
- "bc"
- #
- # Recursive descent operator test
- #
- ..
- [{"a": 1}]
- [{"a": 1}]
- {"a": 1}
- 1
- #
- # Recursive descent operator test 2
- #
- ..
- {"a": 1}
- {"a": 1}
- 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement