blob: eb2282ec6f06c6c9906ba4f4391c45ca7a871d3c [file] [log] [blame]
library;
import self as self;
import "dart:core" as core;
static method test1(dynamic x) dynamic {
core::int i;
{
hoisted dynamic i;
{
final synthesized dynamic #0#0 = x as{TypeError,ForDynamic} core::List<dynamic>;
if(!(#0#0 is core::List<dynamic> && #0#0{core::List<dynamic>}.{core::List::length}{core::int} =={core::num::==}{(core::Object) → core::bool} #C1 && (let final dynamic #t1 = i = #0#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic} in true)))
throw{for-error-handling} new core::StateError::•("Pattern matching error");
}
final dynamic #t2 = i;
for (dynamic i = #t2; true; ) {
return i;
}
}
}
static method test2(dynamic x) dynamic {
{
hoisted core::int i;
{
final synthesized dynamic #0#0 = x as{TypeError,ForDynamic} core::List<core::int>;
synthesized dynamic #0#6;
synthesized core::bool #0#6#isSet = false;
if(!(#0#0 is core::List<dynamic> && #0#0{core::List<dynamic>}.{core::List::length}{core::int} =={core::num::==}{(core::Object) → core::bool} #C1 && ((#0#6#isSet ?{dynamic} #0#6{dynamic} : let final core::bool #t3 = #0#6#isSet = true in #0#6 = #0#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic}) is core::int && (let final core::int #t4 = i = (#0#6#isSet ?{dynamic} #0#6{dynamic} : let final core::bool #t5 = #0#6#isSet = true in #0#6 = #0#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic}) as{Unchecked} core::int in true))))
throw{for-error-handling} new core::StateError::•("Pattern matching error");
}
final core::int #t6 = i;
for (core::int i = #t6; i.{core::num::<}(3){(core::num) → core::bool}; i = i.{core::num::+}(1){(core::num) → core::int}) {
core::int i = 1.{core::int::unary-}(){() core::int};
return i;
}
}
}
static method test3(dynamic x) dynamic {
core::List<() core::int> functions = core::_GrowableList::•<() core::int>(0);
{
hoisted core::int i;
{
final synthesized dynamic #0#0 = x as{TypeError,ForDynamic} core::List<core::int>;
synthesized dynamic #0#6;
synthesized core::bool #0#6#isSet = false;
if(!(#0#0 is core::List<dynamic> && #0#0{core::List<dynamic>}.{core::List::length}{core::int} =={core::num::==}{(core::Object) → core::bool} #C1 && ((#0#6#isSet ?{dynamic} #0#6{dynamic} : let final core::bool #t7 = #0#6#isSet = true in #0#6 = #0#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic}) is core::int && (let final core::int #t8 = i = (#0#6#isSet ?{dynamic} #0#6{dynamic} : let final core::bool #t9 = #0#6#isSet = true in #0#6 = #0#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic}) as{Unchecked} core::int in true))))
throw{for-error-handling} new core::StateError::•("Pattern matching error");
}
final core::int #t10 = i;
for (core::int i = #t10; i.{core::num::<}(5){(core::num) → core::bool}; i = i.{core::num::+}(1){(core::num) → core::int}) {
functions.{core::List::add}(() core::int => i){(() core::int) void};
}
}
return functions.{core::Iterable::map}<core::int>((() core::int f) core::int => f(){() core::int}){((() core::int) core::int) core::Iterable<core::int>}.{core::Iterable::fold}<core::int>(0, (core::int a, core::int x) core::int => a.{core::num::+}(x){(core::num) core::int}){(core::int, (core::int, core::int) core::int) core::int};
}
static method main() dynamic {
self::expectEquals(self::test1(core::_GrowableList::_literal1<core::int>(0)), 0);
self::expectThrows(() void => self::test1("foo"));
self::expectEquals(self::test2(core::_GrowableList::_literal1<core::int>(0)), 1.{core::int::unary-}(){() core::int});
self::expectEquals(self::test3(core::_GrowableList::_literal1<core::int>(0)), 10);
}
static method expectEquals(dynamic x, dynamic y) dynamic {
if(!(x =={core::Object::==}{(core::Object) core::bool} y)) {
throw "Expected '${x}' to be equal to '${y}'.";
}
}
static method expectThrows(() void f) dynamic {
core::bool hasThrown = true;
try {
f(){() void};
hasThrown = false;
}
on core::Object catch(final core::Object e) {
}
if(!hasThrown) {
throw "Expected the function to throw.";
}
}
constants {
#C1 = 1
}
Extra constant evaluation status:
Evaluated: InstanceInvocation @ org-dartlang-testcase:///variable_scoping_in_pattern_for_statements.dart:14:13 -> IntConstant(-1)
Evaluated: InstanceInvocation @ org-dartlang-testcase:///variable_scoping_in_pattern_for_statements.dart:31:28 -> IntConstant(-1)
Extra constant evaluation: evaluated: 143, effectively constant: 2