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

Unified Diff: tools/testing/dart/test_status_expressions.dart

Issue 8394043: Start adding files for Dart version of test script test.py. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments, added and tested boolean variables. Created 9 years, 2 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: tools/testing/dart/test_status_expressions.dart
diff --git a/tools/testing/dart/test_status_expressions.dart b/tools/testing/dart/test_status_expressions.dart
new file mode 100644
index 0000000000000000000000000000000000000000..5fe40909863f3f11e742edb597c7e9179c3cb251
--- /dev/null
+++ b/tools/testing/dart/test_status_expressions.dart
@@ -0,0 +1,100 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
Mads Ager (google) 2011/10/27 07:07:47 This file should be moved to tests/standalone/Test
William Hesse 2011/10/27 15:04:35 Done.
+// 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("status_expressions_lib.dart");
+
+main() {
Mads Ager (google) 2011/10/27 07:07:47 I would move main to the bottom of the file. I bel
William Hesse 2011/10/27 15:04:35 Done.
+ TestStatusExpressions.doTests();
+}
+
+class TestStatusExpressions {
+ static void doTests() {
+ test_1();
kasperl 2011/10/27 10:43:31 camelCase -- no underscores
+ test_2();
+ test_3();
+ test_4();
+ test_5();
+ test_6();
+ }
+
+ static void test_1() {
+ Tokenizer tokenizer = new Tokenizer(
+ @" $mode == debug && ($arch == chromium || $arch == dartc) ");
+ tokenizer.tokenize();
+ Expect.listEquals(tokenizer.tokens,
+ ["\$", "mode", "==", "debug", "&&", "(", "\$", "arch", "==",
+ "chromium", "||", "\$", "arch", "==", "dartc", ")"]);
+ ExpressionParser parser =
+ new ExpressionParser(new Scanner(tokenizer.tokens));
+ BooleanExpression ast = parser.parseBooleanExpression();
+ Expect.equals(
+ @"(($mode == debug) && (($arch == chromium) || ($arch == dartc)))",
+ ast.toString());
Mads Ager (google) 2011/10/27 07:07:47 For all of the ASTs that we generate we should cal
William Hesse 2011/10/27 15:04:35 Done.
+ }
+
+ static void test_2() {
+ Tokenizer tokenizer = new Tokenizer(
+ @"($arch == dartc || $arch == chromium) && $mode == release");
+ tokenizer.tokenize();
+ Expect.listEquals(tokenizer.tokens,
+ ["(", "\$", "arch", "==", "dartc", "||", "\$", "arch", "==", "chromium",
+ ")", "&&", "\$", "mode", "==", "release"]);
+ }
+
+ static void test_3() {
+ var thrown;
+ Tokenizer tokenizer = new Tokenizer(
+ @" $mode == debug && ($arch == chromium || *$arch == dartc) ");
Mads Ager (google) 2011/10/27 07:07:47 Extract this string into a variable and use it in
William Hesse 2011/10/27 15:04:35 Done.
+ try {
+ tokenizer.tokenize();
+ } catch (Exception e) {
+ thrown = e;
+ }
+ Expect.equals(
+ @"Syntax error in ' $mode == debug && ($arch == chromium || *$arch == " +
+ @"dartc) '",
+ thrown.toString());
+ }
+
+ static void test_4() {
+ var thrown;
+ Tokenizer tokenizer = new Tokenizer(
+ @"($arch == (-dartc || $arch == chromium) && $mode == release");
Mads Ager (google) 2011/10/27 07:07:47 Same here.
William Hesse 2011/10/27 15:04:35 Done.
+ try {
+ tokenizer.tokenize();
+ } catch (Exception e) {
+ thrown = e;
+ }
+ Expect.equals(
+ @"Syntax error in '($arch == (-dartc || $arch == chromium) && " +
+ @"$mode == release'",
+ thrown.toString());
+ }
+
+ static void test_5() {
+ Tokenizer tokenizer = new Tokenizer(
+ @"Skip , Pass if $arch == dartc, Fail || Timeout if " +
+ @"$arch == chromium && $mode == release");
+ tokenizer.tokenize();
+ ExpressionParser parser =
+ new ExpressionParser(new Scanner(tokenizer.tokens));
+ SetExpression ast = parser.parseSetExpression();
+ Expect.equals(
+ @"((Skip || (Pass if ($arch == dartc))) || ((Fail || Timeout) " +
+ @"if (($arch == chromium) && ($mode == release))))",
+ ast.toString());
+ }
+
+ static void test_6() {
+ Tokenizer tokenizer = new Tokenizer(
+ @" $arch == ia32 && $checked || $mode == release ");
+ tokenizer.tokenize();
+ ExpressionParser parser =
+ new ExpressionParser(new Scanner(tokenizer.tokens));
+ BooleanExpression ast = parser.parseBooleanExpression();
+ Expect.equals(
+ @"((($arch == ia32) && (bool $checked)) || ($mode == release))",
+ ast.toString());
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698