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

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: 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
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..45111f4a2da3615299386ae9bd7335d0ced63a49
--- /dev/null
+++ b/samples/buildbot/tests/json_test.dart
@@ -0,0 +1,38 @@
+// 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(
+ [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.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());
Anders Johnsen 2015/03/05 07:35:31 Expect.throws(() => new JsonParser('[1 2 3 4 5]').
zerny-google 2015/03/05 08:12:31 Done.
+}
« samples/buildbot/json.dart ('K') | « samples/buildbot/model.dart ('k') | tools/test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698