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

Unified Diff: tests/compiler/dart2js/platform_config_parser_test.dart

Issue 1408253006: Introduce "platform configurations" to replace categories and libraries.dart. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix create_sdk scripts according to review Created 5 years, 1 month 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 | « tests/compiler/dart2js/mock_libraries.dart ('k') | tests/compiler/dart2js/platform_consistency_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/platform_config_parser_test.dart
diff --git a/tests/compiler/dart2js/platform_config_parser_test.dart b/tests/compiler/dart2js/platform_config_parser_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..a25e2da1d6c66d1d1013bf3aa6d84a60d5b8a34f
--- /dev/null
+++ b/tests/compiler/dart2js/platform_config_parser_test.dart
@@ -0,0 +1,130 @@
+// Copyright (c) 2015, 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.
+
+import "package:compiler/src/platform_configuration.dart";
+import "package:expect/expect.dart";
+
+/// Runs the parser on [input] and compares it with [expectedResult]
+///
+/// A '*' in [input] indicates that the parser will report an error at the
+/// given point (On [input] with the "*" removed).
+test(String input, [Map<String, Map<String, String>> expectedOutput]) {
+ int starIndex = input.indexOf("*");
+ String inputWithoutStar = input.replaceFirst("*", "");
+
+ parse() => parseIni(inputWithoutStar.codeUnits,
+ allowedSections: new Set.from(["AA", "BB"]));
+
+ if (starIndex != -1) {
+ Expect.equals(expectedOutput, null);
+ Expect.throws(parse, (e) {
+ Expect.isTrue(e is FormatException);
+ Expect.equals(starIndex, e.offset);
+ return e is FormatException;
+ });
+ } else {
+ Map<String, Map<String, String>> result = parse();
+ Expect.equals(expectedOutput.length, result.length);
+ expectedOutput.forEach((String name, Map<String, String> properties) {
+ Expect.isTrue(expectedOutput.containsKey(name), "Missing section $name");
+ Expect.mapEquals(expectedOutput[name], properties);
+ });
+ }
+}
+
+main() {
+ // Empty file.
+ test(
+ """
+# Nothing here
+""",
+ {});
+
+ // Text outside section.
+ test("""
+*aaa
+""");
+
+ // Malformed header.
+ test("""
+*[AABC
+name:value
+""");
+
+ // Text after header.
+ test("""
+[AABC]*abcde
+""");
+
+ // Empty section name.
+ test("""
+[*]
+""");
+
+ // Duplicate section name.
+ test("""
+[AA]
+[BB]
+[*AA]
+""");
+
+ // Unrecognized section name.
+ test("""
+[*CC]
+""");
+
+ // Empty property name.
+ test("""
+[AA]
+*:value
+name:value
+""");
+
+ // Ok.
+ test(
+ """
+[AA]
+name:value
+[BB]
+name:value
+name2:value2
+""",
+ {
+ "AA": {"name": "value"},
+ "BB": {"name": "value", "name2": "value2"}
+ });
+
+ // Ok, file not ending in newline.
+ test(
+ """
+[AA]
+name:value""",
+ {
+ "A": {"name": "value"}
+ });
+
+ // Ok, whitespace is trimmed away.
+ test(
+ """
+[ AA ]
+ name\t: value """,
+ {
+ "A": {"name": "value"}
+ });
+
+ // Duplicate property name.
+ test("""
+[AA]
+a:b
+b:c
+*a:c
+""");
+
+ // No ':' on property line.
+ test("""
+[AA]
+*name1
+name2:value
+""");
+}
« no previous file with comments | « tests/compiler/dart2js/mock_libraries.dart ('k') | tests/compiler/dart2js/platform_consistency_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698