| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2015, the Fletch project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 |
| 5 import 'dart:io'; |
| 6 |
| 7 import 'package:expect/expect.dart'; |
| 8 |
| 9 import '../json.dart'; |
| 10 |
| 11 void main() { |
| 12 testParser(); |
| 13 } |
| 14 |
| 15 void testParser() { |
| 16 Expect.equals(null, new JsonParser('null').parse()); |
| 17 Expect.equals(true, new JsonParser('true').parse()); |
| 18 Expect.equals(false, new JsonParser('false').parse()); |
| 19 Expect.equals(42, new JsonParser('42').parse()); |
| 20 Expect.equals("hello world", new JsonParser('"hello world"').parse()); |
| 21 |
| 22 Expect.listEquals([], new JsonParser('[]').parse()); |
| 23 Expect.listEquals([], new JsonParser(' [ ] ').parse()); |
| 24 Expect.listEquals([42], new JsonParser('[42]').parse()); |
| 25 Expect.listEquals([42], new JsonParser(' [ 42 ] ').parse()); |
| 26 |
| 27 Expect.listEquals( |
| 28 [true, "hello world", 42], |
| 29 new JsonParser('[true,"hello world",42]').parse()); |
| 30 |
| 31 Expect.listEquals( |
| 32 [true, "hello world", 42], |
| 33 new JsonParser(' [ true , "hello world" , 42 ] ').parse()); |
| 34 |
| 35 Expect.throws(() => new JsonParser('[1 2 3]').parse()); |
| 36 |
| 37 Expect.mapEquals({}, new JsonParser('{}').parse()); |
| 38 Expect.mapEquals({}, new JsonParser(' { } ').parse()); |
| 39 Expect.mapEquals({"x":42}, new JsonParser('{"x":42}').parse()); |
| 40 Expect.mapEquals({"x":42}, new JsonParser(' { "x" : 42 } ').parse()); |
| 41 |
| 42 Expect.mapEquals( |
| 43 {"foo":true, "bar":"hello world", "baz":42}, |
| 44 new JsonParser('{"foo":true,"bar":"hello world","baz":42}').parse()); |
| 45 |
| 46 Expect.mapEquals( |
| 47 {"foo":true, "bar":"hello world", "baz":42}, |
| 48 new JsonParser(' { "foo" :\t true , "bar" : "hello world" , "baz" : 42 } ') |
| 49 .parse()); |
| 50 |
| 51 Expect.throws(() => new JsonParser('{"x"}').parse()); |
| 52 Expect.throws(() => new JsonParser('{42}').parse()); |
| 53 Expect.throws(() => new JsonParser('{"x":1 "y":2}').parse()); |
| 54 } |
| OLD | NEW |