@@ -4,14 +4,14 @@ defmodule Jason.DecodeTest do
4
4
alias Jason.DecodeError
5
5
6
6
test "numbers" do
7
- assert_fail_with "-" , " unexpected end of input at position 1"
8
- assert_fail_with "--1" , " unexpected byte at position 1: 0x2D ('-')"
9
- assert_fail_with "01" , " unexpected byte at position 1: 0x31 ('1')"
10
- assert_fail_with ".1" , " unexpected byte at position 0: 0x2E ('.')"
11
- assert_fail_with "1." , " unexpected end of input at position 2"
12
- assert_fail_with "1e" , " unexpected end of input at position 2"
13
- assert_fail_with "1.0e+" , " unexpected end of input at position 5"
14
- assert_fail_with "1e999" , " unexpected sequence at position 0: \ " 1e999\" "
7
+ assert_fail_with "-" , ~S | unexpected end of input at position 1|
8
+ assert_fail_with "--1" , ~S | unexpected byte at position 1: 0x2D ("-") |
9
+ assert_fail_with "01" , ~S | unexpected byte at position 1: 0x31 ("1") |
10
+ assert_fail_with ".1" , ~S | unexpected byte at position 0: 0x2E (".") |
11
+ assert_fail_with "1." , ~S | unexpected end of input at position 2|
12
+ assert_fail_with "1e" , ~S | unexpected end of input at position 2|
13
+ assert_fail_with "1.0e+" , ~S | unexpected end of input at position 5|
14
+ assert_fail_with "1e999" , ~S | unexpected sequence at position 0: "1e999" |
15
15
16
16
assert parse! ( "0" ) == 0
17
17
assert parse! ( "1" ) == 1
@@ -33,17 +33,18 @@ defmodule Jason.DecodeTest do
33
33
assert parse! ( "123456789.123456789e123" ) == 123456789.123456789e123
34
34
end
35
35
test "strings" do
36
- assert_fail_with ~s( ") , "unexpected end of input at position 1"
37
- assert_fail_with ~s( "\\ ") , "unexpected end of input at position 3"
38
- assert_fail_with ~s( "\\ k") , "unexpected byte at position 2: 0x6B ('k')"
39
- assert_fail_with << ?\" , 128 , ?\" >> , "unexpected byte at position 1: 0x80"
40
- assert_fail_with ~s( "\\ u2603\\ ") , "unexpected end of input at position 9"
41
- assert_fail_with ~s( "Here's a snowman for you: ☃. Good day!) , "unexpected end of input at position 41"
42
- assert_fail_with ~s( "𝄞) , "unexpected end of input at position 5"
43
- assert_fail_with ~s( \u001F ) , "unexpected byte at position 0: 0x1F"
44
- assert_fail_with ~s( "\\ ud8aa\\ udcxx") , "unexpected sequence at position 7: \" \\ \\ udcxx\" "
45
- assert_fail_with ~s( "\\ ud8aa\\ uda00") , "unexpected sequence at position 1: \" \\ \\ ud8aa\\ \\ uda00\" "
46
- assert_fail_with ~s( "\\ uxxxx") , "unexpected sequence at position 1: \" \\ \\ uxxxx\" "
36
+ assert_fail_with ~s( ") , ~S| unexpected end of input at position 1|
37
+ assert_fail_with ~s( "\\ ") , ~S| unexpected end of input at position 3|
38
+ assert_fail_with ~s( "\\ k") , ~S| unexpected byte at position 2: 0x6B ("k")|
39
+ assert_fail_with ~s( "a\r ") , ~S| unexpected byte at position 2: 0xD ("\r")|
40
+ assert_fail_with << ?\" , 128 , ?\" >> , ~S| unexpected byte at position 1: 0x80|
41
+ assert_fail_with ~s( "\\ u2603\\ ") , ~S| unexpected end of input at position 9|
42
+ assert_fail_with ~s( "Here's a snowman for you: ☃. Good day!) , ~S| unexpected end of input at position 41|
43
+ assert_fail_with ~s( "𝄞) , ~S| unexpected end of input at position 5|
44
+ assert_fail_with ~s( \u001F ) , ~S| unexpected byte at position 0: 0x1F|
45
+ assert_fail_with ~s( "\\ ud8aa\\ udcxx") , ~S| unexpected sequence at position 7: "\\udcxx"|
46
+ assert_fail_with ~s( "\\ ud8aa\\ uda00") , ~S| unexpected sequence at position 1: "\\ud8aa\\uda00"|
47
+ assert_fail_with ~s( "\\ uxxxx") , ~S| unexpected sequence at position 1: "\\uxxxx"|
47
48
48
49
assert parse! ( ~s( "\\ "\\ \\ \\ /\\ b\\ f\\ n\\ r\\ t") ) == ~s( "\\ /\b \f \n \r \t )
49
50
assert parse! ( ~s( "\\ u2603") ) == "☃"
@@ -55,10 +56,10 @@ defmodule Jason.DecodeTest do
55
56
end
56
57
57
58
test "objects" do
58
- assert_fail_with "{" , " unexpected end of input at position 1"
59
- assert_fail_with "{," , " unexpected byte at position 1: 0x2C (',')"
60
- assert_fail_with ~s( {"foo"}) , " unexpected byte at position 6: 0x7D ('}')"
61
- assert_fail_with ~s( {"foo": "bar",}) , " unexpected byte at position 14: 0x7D ('}')"
59
+ assert_fail_with "{" , ~S | unexpected end of input at position 1|
60
+ assert_fail_with "{," , ~S | unexpected byte at position 1: 0x2C (",") |
61
+ assert_fail_with ~s( {"foo"}) , ~S | unexpected byte at position 6: 0x7D ("}") |
62
+ assert_fail_with ~s( {"foo": "bar",}) , ~S | unexpected byte at position 14: 0x7D ("}") |
62
63
63
64
assert parse! ( "{}" ) == % { }
64
65
assert parse! ( ~s( {"foo": "bar"}) ) == % { "foo" => "bar" }
@@ -111,9 +112,9 @@ defmodule Jason.DecodeTest do
111
112
end
112
113
113
114
test "arrays" do
114
- assert_fail_with "[" , " unexpected end of input at position 1"
115
- assert_fail_with "[," , " unexpected byte at position 1: 0x2C (',')"
116
- assert_fail_with "[1,]" , " unexpected byte at position 3: 0x5D (']')"
115
+ assert_fail_with "[" , ~S | unexpected end of input at position 1|
116
+ assert_fail_with "[," , ~S | unexpected byte at position 1: 0x2C (",") |
117
+ assert_fail_with "[1,]" , ~S | unexpected byte at position 3: 0x5D ("]") |
117
118
118
119
assert parse! ( "[]" ) == [ ]
119
120
assert parse! ( "[1, 2, 3]" ) == [ 1 , 2 , 3 ]
@@ -122,8 +123,8 @@ defmodule Jason.DecodeTest do
122
123
end
123
124
124
125
test "whitespace" do
125
- assert_fail_with "" , " unexpected end of input at position 0"
126
- assert_fail_with " " , " unexpected end of input at position 4"
126
+ assert_fail_with "" , ~S | unexpected end of input at position 0|
127
+ assert_fail_with " " , ~S | unexpected end of input at position 4|
127
128
128
129
assert parse! ( " [ ] " ) == [ ]
129
130
assert parse! ( " { } " ) == % { }
0 commit comments