123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- [
- {
- "given": {
- "foo": [{"name": "a"}, {"name": "b"}],
- "bar": {"baz": "qux"}
- },
- "cases": [
- {
- "expression": "`\"foo\"`",
- "result": "foo"
- },
- {
- "comment": "Interpret escaped unicode.",
- "expression": "`\"\\u03a6\"`",
- "result": "Φ"
- },
- {
- "expression": "`\"✓\"`",
- "result": "✓"
- },
- {
- "expression": "`[1, 2, 3]`",
- "result": [1, 2, 3]
- },
- {
- "expression": "`{\"a\": \"b\"}`",
- "result": {"a": "b"}
- },
- {
- "expression": "`true`",
- "result": true
- },
- {
- "expression": "`false`",
- "result": false
- },
- {
- "expression": "`null`",
- "result": null
- },
- {
- "expression": "`0`",
- "result": 0
- },
- {
- "expression": "`1`",
- "result": 1
- },
- {
- "expression": "`2`",
- "result": 2
- },
- {
- "expression": "`3`",
- "result": 3
- },
- {
- "expression": "`4`",
- "result": 4
- },
- {
- "expression": "`5`",
- "result": 5
- },
- {
- "expression": "`6`",
- "result": 6
- },
- {
- "expression": "`7`",
- "result": 7
- },
- {
- "expression": "`8`",
- "result": 8
- },
- {
- "expression": "`9`",
- "result": 9
- },
- {
- "comment": "Escaping a backtick in quotes",
- "expression": "`\"foo\\`bar\"`",
- "result": "foo`bar"
- },
- {
- "comment": "Double quote in literal",
- "expression": "`\"foo\\\"bar\"`",
- "result": "foo\"bar"
- },
- {
- "expression": "`\"1\\`\"`",
- "result": "1`"
- },
- {
- "comment": "Multiple literal expressions with escapes",
- "expression": "`\"\\\\\"`.{a:`\"b\"`}",
- "result": {"a": "b"}
- },
- {
- "comment": "literal . identifier",
- "expression": "`{\"a\": \"b\"}`.a",
- "result": "b"
- },
- {
- "comment": "literal . identifier . identifier",
- "expression": "`{\"a\": {\"b\": \"c\"}}`.a.b",
- "result": "c"
- },
- {
- "comment": "literal . identifier bracket-expr",
- "expression": "`[0, 1, 2]`[1]",
- "result": 1
- }
- ]
- },
- {
- "comment": "Literals",
- "given": {"type": "object"},
- "cases": [
- {
- "comment": "Literal with leading whitespace",
- "expression": "` {\"foo\": true}`",
- "result": {"foo": true}
- },
- {
- "comment": "Literal with trailing whitespace",
- "expression": "`{\"foo\": true} `",
- "result": {"foo": true}
- },
- {
- "comment": "Literal on RHS of subexpr not allowed",
- "expression": "foo.`\"bar\"`",
- "error": "syntax"
- }
- ]
- },
- {
- "comment": "Raw String Literals",
- "given": {},
- "cases": [
- {
- "expression": "'foo'",
- "result": "foo"
- },
- {
- "expression": "' foo '",
- "result": " foo "
- },
- {
- "expression": "'0'",
- "result": "0"
- },
- {
- "expression": "'newline\n'",
- "result": "newline\n"
- },
- {
- "expression": "'\n'",
- "result": "\n"
- },
- {
- "expression": "'✓'",
- "result": "✓"
- },
- {
- "expression": "'𝄞'",
- "result": "𝄞"
- },
- {
- "expression": "' [foo] '",
- "result": " [foo] "
- },
- {
- "expression": "'[foo]'",
- "result": "[foo]"
- },
- {
- "comment": "Do not interpret escaped unicode.",
- "expression": "'\\u03a6'",
- "result": "\\u03a6"
- },
- {
- "comment": "Can escape the single quote",
- "expression": "'foo\\'bar'",
- "result": "foo'bar"
- },
- {
- "comment": "Backslash not followed by single quote is treated as any other character",
- "expression": "'\\z'",
- "result": "\\z"
- },
- {
- "comment": "Backslash not followed by single quote is treated as any other character",
- "expression": "'\\\\'",
- "result": "\\\\"
- }
- ]
- }
- ]
|