|
13 | 13 | // limitations under the License.
|
14 | 14 |
|
15 | 15 | ///|
|
16 |
| -test "to_json for tuple of 2 elements" { |
| 16 | +test "2-tuple to_json" { |
17 | 17 | let pair = (42, "hello")
|
18 | 18 | @json.inspect!(pair, content=[42, "hello"])
|
19 | 19 | }
|
20 | 20 |
|
| 21 | +///| |
| 22 | +test "3-tuple to_json" { |
| 23 | + let triple = (42, "hello", true) |
| 24 | + @json.inspect!(triple, content=[42, "hello", true]) |
| 25 | +} |
| 26 | + |
21 | 27 | ///|
|
22 | 28 | test "4-tuple to_json" {
|
23 |
| - let tuple : (Int, String, Bool, Double) = (42, "hello", true, 3.14) |
| 29 | + let tuple = (42, "hello", true, 3.14) |
24 | 30 | @json.inspect!(tuple, content=[42, "hello", true, 3.14])
|
25 | 31 | }
|
| 32 | + |
| 33 | +///| |
| 34 | +test "5-tuple to_json" { |
| 35 | + let tuple = (42, "hello", true, 3.14, 'a') |
| 36 | + @json.inspect!(tuple, content=[42, "hello", true, 3.14, "a"]) |
| 37 | +} |
| 38 | + |
| 39 | +///| |
| 40 | +test "6-tuple to_json" { |
| 41 | + let tuple = (42, "hello", true, 3.14, 'a', 1) |
| 42 | + @json.inspect!(tuple, content=[42, "hello", true, 3.14, "a", 1]) |
| 43 | +} |
| 44 | + |
| 45 | +///| |
| 46 | +test "7-tuple to_json" { |
| 47 | + let tuple = (42, "hello", true, 3.14, 'a', 1, "world") |
| 48 | + @json.inspect!(tuple, content=[42, "hello", true, 3.14, "a", 1, "world"]) |
| 49 | +} |
| 50 | + |
| 51 | +///| |
| 52 | +test "8-tuple to_json" { |
| 53 | + let tuple = (42, "hello", true, 3.14, 'a', 1, "world", false) |
| 54 | + @json.inspect!(tuple, content=[ |
| 55 | + 42, "hello", true, 3.14, "a", 1, "world", false, |
| 56 | + ]) |
| 57 | +} |
| 58 | + |
| 59 | +///| |
| 60 | +test "9-tuple to_json" { |
| 61 | + let tuple = (42, "hello", true, 3.14, 'a', 1, "world", false, 2.71) |
| 62 | + @json.inspect!(tuple, content=[ |
| 63 | + 42, "hello", true, 3.14, "a", 1, "world", false, 2.71, |
| 64 | + ]) |
| 65 | +} |
| 66 | + |
| 67 | +///| |
| 68 | +test "10-tuple to_json" { |
| 69 | + let tuple = (42, "hello", true, 3.14, 'a', 1, "world", false, 2.71, 'b') |
| 70 | + @json.inspect!(tuple, content=[ |
| 71 | + 42, "hello", true, 3.14, "a", 1, "world", false, 2.71, "b", |
| 72 | + ]) |
| 73 | +} |
| 74 | + |
| 75 | +///| |
| 76 | +test "11-tuple to_json" { |
| 77 | + let tuple = (42, "hello", true, 3.14, 'a', 1, "world", false, 2.71, 'b', 43UL) |
| 78 | + @json.inspect!(tuple, content=[ |
| 79 | + 42, "hello", true, 3.14, "a", 1, "world", false, 2.71, "b", "43", |
| 80 | + ]) |
| 81 | +} |
| 82 | + |
| 83 | +///| |
| 84 | +test "12-tuple to_json" { |
| 85 | + let tuple = ( |
| 86 | + 42, "hello", true, 3.14, 'a', 1, "world", false, 2.71, 'b', 43UL, 0x12345678U, |
| 87 | + ) |
| 88 | + @json.inspect!(tuple, content=[ |
| 89 | + 42, "hello", true, 3.14, "a", 1, "world", false, 2.71, "b", "43", 305419896, |
| 90 | + ]) |
| 91 | +} |
| 92 | + |
| 93 | +///| |
| 94 | +test "13-tuple to_json" { |
| 95 | + let tuple = ( |
| 96 | + 42, "hello", true, 3.14, 'a', 1, "world", false, 2.71, 'b', 43UL, 0x12345678U, |
| 97 | + 0x87654321L, |
| 98 | + ) |
| 99 | + @json.inspect!(tuple, content=[ |
| 100 | + 42, "hello", true, 3.14, "a", 1, "world", false, 2.71, "b", "43", 305419896, |
| 101 | + "2271560481", |
| 102 | + ]) |
| 103 | +} |
| 104 | + |
| 105 | +///| |
| 106 | +test "14-tuple to_json" { |
| 107 | + let tuple = ( |
| 108 | + 42, |
| 109 | + "hello", |
| 110 | + true, |
| 111 | + 3.14, |
| 112 | + 'a', |
| 113 | + 1, |
| 114 | + "world", |
| 115 | + false, |
| 116 | + 2.71, |
| 117 | + 'b', |
| 118 | + 43UL, |
| 119 | + 0x12345678U, |
| 120 | + 0x87654321L, |
| 121 | + (0xabcdef, 1234567890UL), |
| 122 | + ) |
| 123 | + @json.inspect!(tuple, content=[ |
| 124 | + 42, |
| 125 | + "hello", |
| 126 | + true, |
| 127 | + 3.14, |
| 128 | + "a", |
| 129 | + 1, |
| 130 | + "world", |
| 131 | + false, |
| 132 | + 2.71, |
| 133 | + "b", |
| 134 | + "43", |
| 135 | + 305419896, |
| 136 | + "2271560481", |
| 137 | + [11259375, "1234567890"], |
| 138 | + ]) |
| 139 | +} |
| 140 | + |
| 141 | +///| |
| 142 | +test "15-tuple to_json" { |
| 143 | + let tuple = ( |
| 144 | + 42, |
| 145 | + "hello", |
| 146 | + true, |
| 147 | + 3.14, |
| 148 | + 'a', |
| 149 | + 1, |
| 150 | + "world", |
| 151 | + false, |
| 152 | + 2.71, |
| 153 | + 'b', |
| 154 | + 43UL, |
| 155 | + 0x12345678U, |
| 156 | + 0x87654321L, |
| 157 | + (0xabcdef, 1234567890UL), |
| 158 | + (0x12345678UL, 0x87654321UL, 0xabcdefUL), |
| 159 | + ) |
| 160 | + @json.inspect!(tuple, content=[ |
| 161 | + 42, |
| 162 | + "hello", |
| 163 | + true, |
| 164 | + 3.14, |
| 165 | + "a", |
| 166 | + 1, |
| 167 | + "world", |
| 168 | + false, |
| 169 | + 2.71, |
| 170 | + "b", |
| 171 | + "43", |
| 172 | + 305419896, |
| 173 | + "2271560481", |
| 174 | + [11259375, "1234567890"], |
| 175 | + ["305419896", "2271560481", "11259375"], |
| 176 | + ]) |
| 177 | +} |
| 178 | + |
| 179 | +///| |
| 180 | +test "16-tuple to_json" { |
| 181 | + let tuple = ( |
| 182 | + "hello", |
| 183 | + 42, |
| 184 | + true, |
| 185 | + 3.14, |
| 186 | + 'a', |
| 187 | + 1, |
| 188 | + "world", |
| 189 | + false, |
| 190 | + 2.71, |
| 191 | + 'b', |
| 192 | + 43UL, |
| 193 | + 0x12345678U, |
| 194 | + 0x87654321L, |
| 195 | + '码', |
| 196 | + -0.00001, |
| 197 | + ("wow", [0x87654321UL, 1234567890UL]), |
| 198 | + ) |
| 199 | + @json.inspect!(tuple, content=[ |
| 200 | + "hello", |
| 201 | + 42, |
| 202 | + true, |
| 203 | + 3.14, |
| 204 | + "a", |
| 205 | + 1, |
| 206 | + "world", |
| 207 | + false, |
| 208 | + 2.71, |
| 209 | + "b", |
| 210 | + "43", |
| 211 | + 305419896, |
| 212 | + "2271560481", |
| 213 | + "码", |
| 214 | + -0.00001, |
| 215 | + ["wow", ["2271560481", "1234567890"]], |
| 216 | + ]) |
| 217 | +} |
0 commit comments