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

Unified Diff: tests/kernel/unsorted/block_scope_test.dart

Issue 2434123003: Merge more Kernel infrastructure from kernel_sdk SDK fork. (Closed)
Patch Set: address more comments Created 4 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: tests/kernel/unsorted/block_scope_test.dart
diff --git a/tests/kernel/unsorted/block_scope_test.dart b/tests/kernel/unsorted/block_scope_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..ae54352a81e984cd0fae908eddd1fd02602f7642
--- /dev/null
+++ b/tests/kernel/unsorted/block_scope_test.dart
@@ -0,0 +1,60 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// 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.
+
+// Tests of block scoping.
+
+import 'expect.dart';
+
+bool oracle() => true;
+
+test0() {
+ var x = 'outer', y = x;
+ Expect.isTrue(x == 'outer');
+ Expect.isTrue(y == 'outer');
+ { var x = 'inner';
+ Expect.isTrue(x == 'inner');
+ Expect.isTrue(y == 'outer');
+ }
+ Expect.isTrue(x == 'outer');
+ Expect.isTrue(y == 'outer');
+
+ if (oracle()) {
+ var y = 'inner';
+ Expect.isTrue(x == 'outer');
+ Expect.isTrue(y == 'inner');
+ } else {
+ Expect.isTrue(false);
+ }
+ Expect.isTrue(x == 'outer');
+ Expect.isTrue(y == 'outer');
+}
+
+var x = 'toplevel';
+
+test1() {
+ var y = 'outer';
+ Expect.isTrue(x == 'toplevel');
+ Expect.isTrue(y == 'outer');
+ { var x = 'inner';
+ Expect.isTrue(x == 'inner');
+ Expect.isTrue(y == 'outer');
+ }
+ Expect.isTrue(x == 'toplevel');
+ Expect.isTrue(y == 'outer');
+
+ if (oracle()) {
+ var y = 'inner';
+ Expect.isTrue(x == 'toplevel');
+ Expect.isTrue(y == 'inner');
+ } else {
+ Expect.isTrue(false);
+ }
+ Expect.isTrue(x == 'toplevel');
+ Expect.isTrue(y == 'outer');
+}
+
+main() {
+ test0();
+ test1();
+}

Powered by Google App Engine
This is Rietveld 408576698