Chromium Code Reviews| 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.
|
| +} |