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

Side by Side Diff: tests/standalone/status_expression_test.dart

Issue 10414002: More String + elimination in tests (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #library("StatusExpressionTest"); 5 #library("StatusExpressionTest");
6 6
7 #import("../../tools/testing/dart/status_expression.dart"); 7 #import("../../tools/testing/dart/status_expression.dart");
8 8
9 9
10 class StatusExpressionTest { 10 class StatusExpressionTest {
(...skipping 24 matching lines...) Expand all
35 environment["arch"] = "dartc"; 35 environment["arch"] = "dartc";
36 environment["mode"] = "debug"; 36 environment["mode"] = "debug";
37 Expect.isTrue(ast.evaluate(environment)); 37 Expect.isTrue(ast.evaluate(environment));
38 environment["mode"] = "release"; 38 environment["mode"] = "release";
39 Expect.isFalse(ast.evaluate(environment)); 39 Expect.isFalse(ast.evaluate(environment));
40 environment["arch"] = "ia32"; 40 environment["arch"] = "ia32";
41 Expect.isFalse(ast.evaluate(environment)); 41 Expect.isFalse(ast.evaluate(environment));
42 environment["mode"] = "debug"; 42 environment["mode"] = "debug";
43 Expect.isFalse(ast.evaluate(environment)); 43 Expect.isFalse(ast.evaluate(environment));
44 environment["arch"] = "chromium"; 44 environment["arch"] = "chromium";
45 Expect.isTrue(ast.evaluate(environment)); 45 Expect.isTrue(ast.evaluate(environment));
46 } 46 }
47 47
48 static void test2() { 48 static void test2() {
49 Tokenizer tokenizer = new Tokenizer( 49 Tokenizer tokenizer = new Tokenizer(
50 @"($arch == dartc || $arch == chromium) && $mode == release"); 50 @"($arch == dartc || $arch == chromium) && $mode == release");
51 tokenizer.tokenize(); 51 tokenizer.tokenize();
52 Expect.listEquals( 52 Expect.listEquals(
53 tokenizer.tokens, 53 tokenizer.tokens,
54 ["(", "\$", "arch", "==", "dartc", "||", "\$", "arch", "==", 54 ["(", "\$", "arch", "==", "dartc", "||", "\$", "arch", "==",
55 "chromium", ")", "&&", "\$", "mode", "==", "release"]); 55 "chromium", ")", "&&", "\$", "mode", "==", "release"]);
56 } 56 }
57 57
58 static void test3() { 58 static void test3() {
59 var thrown; 59 var thrown;
60 String input = @" $mode == debug && ($arch==chromium || *$arch == dartc)"; 60 String input = @" $mode == debug && ($arch==chromium || *$arch == dartc)";
61 Tokenizer tokenizer = new Tokenizer(input); 61 Tokenizer tokenizer = new Tokenizer(input);
62 try { 62 try {
63 tokenizer.tokenize(); 63 tokenizer.tokenize();
64 } catch (Exception e) { 64 } catch (Exception e) {
65 thrown = e; 65 thrown = e;
66 } 66 }
67 Expect.equals("Syntax error in '$input'", thrown.toString()); 67 Expect.equals("Syntax error in '$input'", thrown.toString());
68 } 68 }
69 69
70 static void test4() { 70 static void test4() {
71 var thrown; 71 var thrown;
72 String input = 72 String input =
73 @"($arch == (-dartc || $arch == chromium) && $mode == release"; 73 @"($arch == (-dartc || $arch == chromium) && $mode == release";
74 Tokenizer tokenizer = new Tokenizer(input); 74 Tokenizer tokenizer = new Tokenizer(input);
75 try { 75 try {
76 tokenizer.tokenize(); 76 tokenizer.tokenize();
77 } catch (Exception e) { 77 } catch (Exception e) {
78 thrown = e; 78 thrown = e;
79 } 79 }
80 Expect.equals("Syntax error in '$input'", thrown.toString()); 80 Expect.equals("Syntax error in '$input'", thrown.toString());
81 } 81 }
82 82
83 static void test5() { 83 static void test5() {
84 Tokenizer tokenizer = new Tokenizer( 84 Tokenizer tokenizer = new Tokenizer(
85 @"Skip , Pass if $arch == dartc, Fail || Timeout if " + 85 @"Skip , Pass if $arch == dartc, Fail || Timeout if "
86 @"$arch == chromium && $mode == release"); 86 @"$arch == chromium && $mode == release");
87 tokenizer.tokenize(); 87 tokenizer.tokenize();
88 ExpressionParser parser = 88 ExpressionParser parser =
89 new ExpressionParser(new Scanner(tokenizer.tokens)); 89 new ExpressionParser(new Scanner(tokenizer.tokens));
90 SetExpression ast = parser.parseSetExpression(); 90 SetExpression ast = parser.parseSetExpression();
91 Expect.equals( 91 Expect.equals(
92 @"((skip || (pass if ($arch == dartc))) || ((fail || timeout) " + 92 @"((skip || (pass if ($arch == dartc))) || ((fail || timeout) "
93 @"if (($arch == chromium) && ($mode == release))))", 93 @"if (($arch == chromium) && ($mode == release))))",
94 ast.toString()); 94 ast.toString());
95 95
96 // Test SetExpression.evaluate(). 96 // Test SetExpression.evaluate().
97 Map environment = new Map(); 97 Map environment = new Map();
98 environment["arch"] = "ia32"; 98 environment["arch"] = "ia32";
99 environment["checked"] = true; 99 environment["checked"] = true;
100 environment["mode"] = "debug"; 100 environment["mode"] = "debug";
101 Set<String> result = ast.evaluate(environment); 101 Set<String> result = ast.evaluate(environment);
102 Expect.setEquals(["skip"], result); 102 Expect.setEquals(["skip"], result);
(...skipping 30 matching lines...) Expand all
133 Expect.isTrue(ast.evaluate(environment)); 133 Expect.isTrue(ast.evaluate(environment));
134 environment["mode"] = "release"; 134 environment["mode"] = "release";
135 Expect.isTrue(ast.evaluate(environment)); 135 Expect.isTrue(ast.evaluate(environment));
136 environment["checked"] = false; 136 environment["checked"] = false;
137 Expect.isTrue(ast.evaluate(environment)); 137 Expect.isTrue(ast.evaluate(environment));
138 environment["mode"] = "debug"; 138 environment["mode"] = "debug";
139 Expect.isFalse(ast.evaluate(environment)); 139 Expect.isFalse(ast.evaluate(environment));
140 environment["arch"] = "arm"; 140 environment["arch"] = "arm";
141 Expect.isFalse(ast.evaluate(environment)); 141 Expect.isFalse(ast.evaluate(environment));
142 environment["checked"] = true; 142 environment["checked"] = true;
143 Expect.isFalse(ast.evaluate(environment)); 143 Expect.isFalse(ast.evaluate(environment));
144 } 144 }
145 } 145 }
146 146
147 main() { 147 main() {
148 StatusExpressionTest.testMain(); 148 StatusExpressionTest.testMain();
149 } 149 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698