| 54 | } |
| 55 | |
| 56 | func TestValueOfJSON1(t *testing.T) { |
| 57 | testCases := []struct { |
| 58 | str string |
| 59 | typ *types.Type |
| 60 | val types.Value |
| 61 | }{ |
| 62 | { |
| 63 | str: "false", |
| 64 | typ: types.NewType("bool"), // we can infer these! |
| 65 | val: &types.BoolValue{V: false}, |
| 66 | }, |
| 67 | { |
| 68 | str: "true", |
| 69 | val: &types.BoolValue{V: true}, |
| 70 | }, |
| 71 | { |
| 72 | str: `""`, // not empty string, but two quotes! |
| 73 | val: &types.StrValue{V: ""}, |
| 74 | }, |
| 75 | { |
| 76 | str: `"hello"`, |
| 77 | val: &types.StrValue{V: "hello"}, |
| 78 | }, |
| 79 | { |
| 80 | str: `"hello\tworld"`, |
| 81 | val: &types.StrValue{V: "hello\tworld"}, |
| 82 | }, |
| 83 | { |
| 84 | str: `"hello\nworld"`, |
| 85 | val: &types.StrValue{V: "hello\nworld"}, |
| 86 | }, |
| 87 | { |
| 88 | str: `"hello\\world"`, |
| 89 | val: &types.StrValue{V: "hello\\world"}, |
| 90 | }, |
| 91 | { |
| 92 | str: `"hello\t\nworld"`, |
| 93 | val: &types.StrValue{V: "hello\t\nworld"}, |
| 94 | }, |
| 95 | { |
| 96 | str: `"\\"`, |
| 97 | val: &types.StrValue{V: "\\"}, |
| 98 | }, |
| 99 | { |
| 100 | str: "0", |
| 101 | val: &types.IntValue{V: 0}, |
| 102 | }, |
| 103 | { |
| 104 | str: "0", |
| 105 | val: &types.IntValue{V: -0}, |
| 106 | }, |
| 107 | { |
| 108 | str: "42", |
| 109 | val: &types.IntValue{V: 42}, |
| 110 | }, |
| 111 | { |
| 112 | str: "-13", |
| 113 | val: &types.IntValue{V: -13}, |