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

Side by Side Diff: tests/standalone/src/StatusExpressionTest.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: Rename file Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/testing/dart/status_expression.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 #import("../../../tools/testing/dart/status_expression.dart");
6
7
8 class StatusExpressionTest {
9 static void testMain() {
10 test1();
11 test2();
12 test3();
13 test4();
14 test5();
15 test6();
16 }
17
18 static void test1() {
19 Tokenizer tokenizer = new Tokenizer(
20 @" $mode == debug && ($arch == chromium || $arch == dartc) ");
21 tokenizer.tokenize();
22 Expect.listEquals(tokenizer.tokens,
23 ["\$", "mode", "==", "debug", "&&", "(", "\$", "arch", "==",
24 "chromium", "||", "\$", "arch", "==", "dartc", ")"]);
25 ExpressionParser parser =
26 new ExpressionParser(new Scanner(tokenizer.tokens));
27 BooleanExpression ast = parser.parseBooleanExpression();
28 Expect.equals(
29 @"(($mode == debug) && (($arch == chromium) || ($arch == dartc)))",
30 ast.toString());
31 // Test BooleanExpression.evaluate().
32 Map<String, String> environment = new Map<String, String>();
33 environment["arch"] = "dartc";
34 environment["mode"] = "debug";
35 Expect.isTrue(ast.evaluate(environment));
36 environment["mode"] = "release";
37 Expect.isFalse(ast.evaluate(environment));
38 environment["arch"] = "ia32";
39 Expect.isFalse(ast.evaluate(environment));
40 environment["mode"] = "debug";
41 Expect.isFalse(ast.evaluate(environment));
42 environment["arch"] = "chromium";
43 Expect.isTrue(ast.evaluate(environment));
44 }
45
46 static void test2() {
47 Tokenizer tokenizer = new Tokenizer(
48 @"($arch == dartc || $arch == chromium) && $mode == release");
49 tokenizer.tokenize();
50 Expect.listEquals(
51 tokenizer.tokens,
52 ["(", "\$", "arch", "==", "dartc", "||", "\$", "arch", "==",
53 "chromium", ")", "&&", "\$", "mode", "==", "release"]);
54 }
55
56 static void test3() {
57 var thrown;
58 String input = @" $mode == debug && ($arch==chromium || *$arch == dartc)";
59 Tokenizer tokenizer = new Tokenizer(input);
60 try {
61 tokenizer.tokenize();
62 } catch (Exception e) {
63 thrown = e;
64 }
65 Expect.equals("Syntax error in '$input'", thrown.toString());
66 }
67
68 static void test4() {
69 var thrown;
70 String input =
71 @"($arch == (-dartc || $arch == chromium) && $mode == release";
72 Tokenizer tokenizer = new Tokenizer(input);
73 try {
74 tokenizer.tokenize();
75 } catch (Exception e) {
76 thrown = e;
77 }
78 Expect.equals("Syntax error in '$input'", thrown.toString());
79 }
80
81 static void test5() {
82 Tokenizer tokenizer = new Tokenizer(
83 @"Skip , Pass if $arch == dartc, Fail || Timeout if " +
84 @"$arch == chromium && $mode == release");
85 tokenizer.tokenize();
86 ExpressionParser parser =
87 new ExpressionParser(new Scanner(tokenizer.tokens));
88 SetExpression ast = parser.parseSetExpression();
89 Expect.equals(
90 @"((Skip || (Pass if ($arch == dartc))) || ((Fail || Timeout) " +
91 @"if (($arch == chromium) && ($mode == release))))",
92 ast.toString());
93
94 // Test SetExpression.evaluate().
95 Map<String, String> environment = new Map<String, String>();
96 environment["arch"] = "ia32";
97 environment["checked"] = "true";
98 environment["mode"] = "debug";
99 Set<String> result = ast.evaluate(environment);
100 Expect.setEquals(["Skip"], result);
101
102 environment["arch"] = "dartc";
103 result = ast.evaluate(environment);
104 Expect.setEquals(["Skip", "Pass"], result);
105
106 environment["arch"] = "chromium";
107 result = ast.evaluate(environment);
108 Expect.setEquals(["Skip"], result);
109
110 environment["mode"] = "release";
111 result = ast.evaluate(environment);
112 Expect.setEquals(["Skip", "Fail", "Timeout"], result);
113 }
114
115 static void test6() {
116 Tokenizer tokenizer = new Tokenizer(
117 @" $arch == ia32 && $checked || $mode == release ");
118 tokenizer.tokenize();
119 ExpressionParser parser =
120 new ExpressionParser(new Scanner(tokenizer.tokens));
121 BooleanExpression ast = parser.parseBooleanExpression();
122 Expect.equals(
123 @"((($arch == ia32) && (bool $checked)) || ($mode == release))",
124 ast.toString());
125
126 // Test BooleanExpression.evaluate().
127 Map<String, String> environment = new Map<String, String>();
128 environment["arch"] = "ia32";
129 environment["checked"] = "true";
130 environment["mode"] = "debug";
131 Expect.isTrue(ast.evaluate(environment));
132 environment["mode"] = "release";
133 Expect.isTrue(ast.evaluate(environment));
134 environment["checked"] = "false";
135 Expect.isTrue(ast.evaluate(environment));
136 environment["mode"] = "debug";
137 Expect.isFalse(ast.evaluate(environment));
138 environment["arch"] = "arm";
139 Expect.isFalse(ast.evaluate(environment));
140 environment["checked"] = "true";
141 Expect.isFalse(ast.evaluate(environment));
142 }
143 }
144
145 main() {
146 StatusExpressionTest.testMain();
147 }
OLDNEW
« no previous file with comments | « no previous file | tools/testing/dart/status_expression.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698