From 441bd85c9f642d56098901e0265d2382c6a20d9b Mon Sep 17 00:00:00 2001 From: "kevmoo@google.com" Date: Wed, 26 Mar 2014 23:11:40 +0000 Subject: [PATCH] Fix JSON tests, re-enable in all cases - 2nd try R=lrn@google.com Review URL: https://codereview.chromium.org//212813006 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@34457 260f80e4-7a28-3924-810f-c04153c831b5 --- tests/json/json.status | 9 ------ .../convert/json2_test.dart} | 32 ++++++++----------- .../io/status_file_parser_test.dart | 1 - tools/status_clean.dart | 1 - tools/test.dart | 1 - 5 files changed, 13 insertions(+), 31 deletions(-) delete mode 100644 tests/json/json.status rename tests/{json/json_test.dart => lib/convert/json2_test.dart} (90%) diff --git a/tests/json/json.status b/tests/json/json.status deleted file mode 100644 index ebf041dcb9a..00000000000 --- a/tests/json/json.status +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright (c) 2012, the Dart 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 file. - -[ $runtime == vm ] -*: Skip - -[ $compiler == dart2js && $runtime == none ] -*: Fail, Pass # TODO(ahe): Triage these tests. diff --git a/tests/json/json_test.dart b/tests/lib/convert/json2_test.dart similarity index 90% rename from tests/json/json_test.dart rename to tests/lib/convert/json2_test.dart index 1c7e4441248..cfb3514241e 100644 --- a/tests/json/json_test.dart +++ b/tests/lib/convert/json2_test.dart @@ -2,15 +2,15 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -library json_tests; -import "package:expect/expect.dart"; -import "dart:convert"; -import 'dart:html'; -import '../../pkg/unittest/lib/unittest.dart'; -import '../../pkg/unittest/lib/html_config.dart'; +library json2_tests; -main() { - useHtmlConfiguration(); +import "dart:convert"; + +import 'package:unittest/unittest.dart'; + +// Moved from "tests/json/json_test.dart" + +void main() { test('Parse', () { // Scalars. expect(JSON.decode(' 5 '), equals(5)); @@ -85,9 +85,8 @@ main() { expect(JSON.encode(null), equals('null')); expect(JSON.encode(' hi there" bob '), equals('" hi there\\" bob "')); expect(JSON.encode('hi\\there'), equals('"hi\\\\there"')); - // TODO(devoncarew): these tests break the dartium build - //expect(JSON.encode('hi\nthere'), equals('"hi\\nthere"')); - //expect(JSON.encode('hi\r\nthere'), equals('"hi\\r\\nthere"')); + expect(JSON.encode('hi\nthere'), equals('"hi\\nthere"')); + expect(JSON.encode('hi\r\nthere'), equals('"hi\\r\\nthere"')); expect(JSON.encode(''), equals('""')); // Lists. @@ -119,14 +118,9 @@ main() { expect(JSON.encode(new ToJson([4, new ToJson({"x":42})])), '[4,{"x":42}]'); - Expect.throws(() { - JSON.encode([new ToJson(new ToJson(4))]); - }); - - Expect.throws(() { - JSON.encode([new Object()]); - }); + expect(() => JSON.encode([new ToJson(new ToJson(4))]), throws); + expect(() => JSON.encode([new Object()]), throws); }); test('stringify throws if argument cannot be converted', () { @@ -168,6 +162,6 @@ class ToJson { * Checks that the argument can be converted to a JSON string and * back, and produce something equivalent to the argument. */ -validateRoundTrip(expected) { +void validateRoundTrip(expected) { expect(JSON.decode(JSON.encode(expected)), equals(expected)); } diff --git a/tests/standalone/io/status_file_parser_test.dart b/tests/standalone/io/status_file_parser_test.dart index 8c120c6c4e4..aabd64574fe 100644 --- a/tests/standalone/io/status_file_parser_test.dart +++ b/tests/standalone/io/status_file_parser_test.dart @@ -19,7 +19,6 @@ void main() { TestReadStatusFile("tests/dom/dom.status"); TestReadStatusFile("tests/html/html.status"); TestReadStatusFile("tests/isolate/isolate.status"); - TestReadStatusFile("tests/json/json.status"); TestReadStatusFile("tests/language/language.status"); TestReadStatusFile("tests/standalone/standalone.status"); } diff --git a/tools/status_clean.dart b/tools/status_clean.dart index c28b1a33b8d..18043ecc033 100644 --- a/tools/status_clean.dart +++ b/tools/status_clean.dart @@ -19,7 +19,6 @@ final STATUS_TUPLES = [ ["corelib", "tests/corelib", "tests/corelib/corelib.status"], ["html", "tests/html", "tests/html/html.status"], ["isolate", "tests/isolate", "tests/isolate/isolate.status"], - ["json", "tests/json", "tests/json/json.status"], ["language", "tests/language", "tests/language/language.status"], ["language", "tests/language", "tests/language/language_analyzer2.status"], ["language","tests/language", "tests/language/language_analyzer.status"], diff --git a/tools/test.dart b/tools/test.dart index 3a6c14ac539..0c9b39b6aac 100755 --- a/tools/test.dart +++ b/tools/test.dart @@ -58,7 +58,6 @@ final TEST_SUITE_DIRECTORIES = [ new Path('tests/corelib'), new Path('tests/html'), new Path('tests/isolate'), - new Path('tests/json'), new Path('tests/language'), new Path('tests/lib'), new Path('tests/standalone'),