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

Unified 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, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samples/buildbot/json.dart ('k') | tools/test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/buildbot/tests/json_test.dart
diff --git a/samples/buildbot/tests/json_test.dart b/samples/buildbot/tests/json_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..67c7fbe30ece6a20e9645fbc5c3ad0ad038a1061
--- /dev/null
+++ b/samples/buildbot/tests/json_test.dart
@@ -0,0 +1,54 @@
+// Copyright (c) 2015, the Fletch project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE.md file.
+
+import 'dart:io';
+
+import 'package:expect/expect.dart';
+
+import '../json.dart';
+
+void main() {
+ testParser();
+}
+
+void testParser() {
+ Expect.equals(null, new JsonParser('null').parse());
+ Expect.equals(true, new JsonParser('true').parse());
+ Expect.equals(false, new JsonParser('false').parse());
+ Expect.equals(42, new JsonParser('42').parse());
+ Expect.equals("hello world", new JsonParser('"hello world"').parse());
+
+ Expect.listEquals([], new JsonParser('[]').parse());
+ Expect.listEquals([], new JsonParser(' [ ] ').parse());
+ Expect.listEquals([42], new JsonParser('[42]').parse());
+ Expect.listEquals([42], new JsonParser(' [ 42 ] ').parse());
+
+ Expect.listEquals(
+ [true, "hello world", 42],
+ new JsonParser('[true,"hello world",42]').parse());
+
+ Expect.listEquals(
+ [true, "hello world", 42],
+ new JsonParser(' [ true , "hello world" , 42 ] ').parse());
+
+ Expect.throws(() => new JsonParser('[1 2 3]').parse());
+
+ Expect.mapEquals({}, new JsonParser('{}').parse());
+ Expect.mapEquals({}, new JsonParser(' { } ').parse());
+ Expect.mapEquals({"x":42}, new JsonParser('{"x":42}').parse());
+ Expect.mapEquals({"x":42}, new JsonParser(' { "x" : 42 } ').parse());
+
+ Expect.mapEquals(
+ {"foo":true, "bar":"hello world", "baz":42},
+ new JsonParser('{"foo":true,"bar":"hello world","baz":42}').parse());
+
+ Expect.mapEquals(
+ {"foo":true, "bar":"hello world", "baz":42},
+ new JsonParser(' { "foo" :\t true , "bar" : "hello world" , "baz" : 42 } ')
+ .parse());
+
+ Expect.throws(() => new JsonParser('{"x"}').parse());
+ Expect.throws(() => new JsonParser('{42}').parse());
+ Expect.throws(() => new JsonParser('{"x":1 "y":2}').parse());
+}
« 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