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..cacabcb9c0a43b96e4d22a82d79e2a4d27f0c1fa |
--- /dev/null |
+++ b/tools/testing/dart/test_status_expressions.dart |
@@ -0,0 +1,73 @@ |
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
Mads Ager (google)
2011/10/26 12:37:47
We need to create a new class of tests in dart/tes
|
+// 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"); |
+ |
+void main() { |
+ TestStatusExpressions.doTests(); |
+} |
+ |
+class TestStatusExpressions { |
+ static void doTests() { |
+ test_1(); |
+ test_2(); |
+ test_3(); |
+ test_4(); |
+ test_5(); |
+ } |
+ |
+ 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(); |
+ print(ast.toString()); |
ngeoffray
2011/10/26 12:01:37
You should not need to call toString when giving s
Mads Ager (google)
2011/10/26 12:37:47
Just remove the print? However, you should verify
|
+ } |
+ |
+ 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"]); |
Mads Ager (google)
2011/10/26 12:37:47
Parse and verify as well?
|
+ } |
+ |
+ static void test_3() { |
Mads Ager (google)
2011/10/26 12:37:47
Use Expect calls so this test can be run by the te
|
+ Tokenizer tokenizer = new Tokenizer( |
+ @" $mode == debug && ($arch == chromium || *$arch == dartc) "); |
+ try { |
+ tokenizer.tokenize(); |
+ } catch (Exception e) { |
+ print(e.toString()); |
+ } |
+ } |
+ |
+ static void test_4() { |
Mads Ager (google)
2011/10/26 12:37:47
Ditto.
|
+ Tokenizer tokenizer = new Tokenizer( |
+ @"($arch == (-dartc || $arch == chromium) && $mode == release"); |
+ try { |
+ tokenizer.tokenize(); |
+ } catch (Exception e) { |
+ print(e.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(); |
+ print(ast.toString()); |
Mads Ager (google)
2011/10/26 12:37:47
Verify the AST with Expect calls.
|
+ |
+ } |
+} |