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

Unified Diff: tests/language/scope_variable_test.dart

Issue 23944004: Merge two language/scope_ tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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
« no previous file with comments | « tests/language/scope_negative_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/scope_variable_test.dart
diff --git a/tests/language/scope_variable_test.dart b/tests/language/scope_variable_test.dart
index d3bca7cc1ea376c779786b683388a00e58d0511c..e07da82a65ed325f34b3dc59d296cc4c36be8cf2 100644
--- a/tests/language/scope_variable_test.dart
+++ b/tests/language/scope_variable_test.dart
@@ -4,38 +4,44 @@
import "package:expect/expect.dart";
-class ScopeVariableTest {
-
- static void testSimpleScope() {
- {
- var a = "Test";
- int b = 1;
- }
- {
- var c;
- int d;
- Expect.equals(true, c == null);
- Expect.equals(true, d == null);
- }
- }
-
- static void testShadowingScope() {
+void testSimpleScope() {
+ {
var a = "Test";
- {
- var a;
- Expect.equals(true, a == null);
- a = "a";
- Expect.equals(true, a == "a");
+ int b = 1;
+ }
+ {
+ var c;
+ int d;
+ Expect.equals(true, c == null);
kustermann 2013/09/04 09:28:42 I'd use one of these two instead: Expect.isTrue
Søren Gjesse 2013/09/04 10:16:16 Done (I just copied some old code). Ended up using
kustermann 2013/09/04 10:19:16 'Expect.isNull' is even better in this case. My c
+ Expect.equals(true, d == null);
}
- Expect.equals(true, a == "Test");
+}
+
+void testShadowingScope() {
+ var a = "Test";
+ {
+ var a;
+ Expect.equals(true, a == null);
+ a = "a";
+ Expect.equals(true, a == "a");
}
+ Expect.equals(true, a == "Test");
+}
- static void testMain() {
- testSimpleScope();
- testShadowingScope();
+int testShadowingAfterUse() {
+ var a = 1;
+ {
+ var b = 2;
+ var c = a; // Use of 'a' prior to its shadow declaration below.
+ var d = b + c;
+ // Shadow declaration of 'a'.
+ var a = 5; /// 01: compile-time error
kustermann 2013/09/04 09:28:42 I wasn't aware that this is supposed to result in
+ return d + a;
}
}
main() {
- ScopeVariableTest.testMain();
+ testSimpleScope();
+ testShadowingScope();
+ testShadowingAfterUse();
}
« no previous file with comments | « tests/language/scope_negative_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698