Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(498)

Side by Side Diff: samples/buildbot/tests/json_test.dart

Issue 967883004: Replace string uses with code units in Json parser. (Closed) Base URL: git@github.com:dart-lang/fletch.git@master
Patch Set: non-optional comma Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « samples/buildbot/json.dart ('k') | tools/test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 }
OLDNEW
« no previous file with comments | « samples/buildbot/json.dart ('k') | tools/test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698