blob: 3534cb308e0b8b795d565c64f3143e797b0b69a4 [file] [log] [blame]
library;
import self as self;
import "dart:core" as core;
static method test1(dynamic x) dynamic {
{
synthesized core::Iterator<dynamic> :sync-for-iterator = (x as{TypeError,ForDynamic} core::Iterable<dynamic>).{core::Iterable::iterator}{core::Iterator<dynamic>};
for (; :sync-for-iterator.{core::Iterator::moveNext}(){() core::bool}; ) {
final dynamic #t1 = :sync-for-iterator.{core::Iterator::current}{dynamic};
{
hoisted core::int y;
{
final synthesized dynamic #0#0 = #t1;
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 #t2 = #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 #t3 = y = (#0#6#isSet ?{dynamic} #0#6{dynamic} : let final core::bool #t4 = #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");
}
if(y.{core::num::%}(10){(core::num) core::int} =={core::num::==}{(core::Object) core::bool} 0) {
return y;
}
}
}
}
return 1.{core::int::unary-}(){() core::int};
}
static method test2(core::Iterable<core::List<core::String>> x) dynamic {
{
synthesized core::Iterator<core::List<core::String>> :sync-for-iterator = x.{core::Iterable::iterator}{core::Iterator<core::List<core::String>>};
for (; :sync-for-iterator.{core::Iterator::moveNext}(){() core::bool}; ) {
final core::List<core::String> #t5 = :sync-for-iterator.{core::Iterator::current}{core::List<core::String>};
{
hoisted core::String y;
{
final synthesized core::List<core::String> #0#0 = #t5;
synthesized core::int #0#1;
synthesized core::bool #0#1#isSet = false;
synthesized core::String #0#4;
synthesized core::bool #0#4#isSet = false;
if(!((#0#1#isSet ?{core::int} #0#1{core::int} : let final core::bool #t6 = #0#1#isSet = true in #0#1 = #0#0.{core::List::length}{core::int}).{core::num::>=}(#C1){(core::num) → core::bool} && ((#0#4#isSet ?{core::String} #0#4{core::String} : let final core::bool #t7 = #0#4#isSet = true in #0#4 = #0#0.{core::List::[]}((#0#1#isSet ?{core::int} #0#1{core::int} : let final core::bool #t8 = #0#1#isSet = true in #0#1 = #0#0.{core::List::length}{core::int}).{core::num::-}(1){(core::num) → core::int}){(core::int) → core::String}) is core::String && (let final core::String #t9 = y = #0#4#isSet ?{core::String} #0#4{core::String} : let final core::bool #t10 = #0#4#isSet = true in #0#4 = #0#0.{core::List::[]}((#0#1#isSet ?{core::int} #0#1{core::int} : let final core::bool #t11 = #0#1#isSet = true in #0#1 = #0#0.{core::List::length}{core::int}).{core::num::-}(1){(core::num) → core::int}){(core::int) → core::String} in true))))
throw{for-error-handling} new core::StateError::•("Pattern matching error");
}
if(y.{core::String::startsWith}("f"){(core::Pattern, [core::int]) core::bool}) {
return y;
}
}
}
}
return "";
}
static method test3(core::Iterable<dynamic> x) dynamic {
{
synthesized core::Iterator<dynamic> :sync-for-iterator = x.{core::Iterable::iterator}{core::Iterator<dynamic>};
for (; :sync-for-iterator.{core::Iterator::moveNext}(){() core::bool}; ) {
final dynamic #t12 = :sync-for-iterator.{core::Iterator::current}{dynamic};
{
hoisted core::int y;
{
final synthesized dynamic #0#0 = #t12;
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::>=}(#C1){(core::num) → core::bool} && ((#0#6#isSet ?{dynamic} #0#6{dynamic} : let final core::bool #t13 = #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 #t14 = y = (#0#6#isSet ?{dynamic} #0#6{dynamic} : let final core::bool #t15 = #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");
}
return y;
}
}
}
return 1.{core::int::unary-}(){() core::int};
}
static method main() dynamic {
self::expectEquals(self::test1(core::_GrowableList::_literal3<core::List<core::int>>(core::_GrowableList::_literal1<core::int>(1), core::_GrowableList::_literal1<core::int>(2), core::_GrowableList::_literal1<core::int>(3))), 1.{core::int::unary-}(){() core::int});
self::expectEquals(self::test1(core::_GrowableList::_literal3<core::List<core::int>>(core::_GrowableList::_literal1<core::int>(1), core::_GrowableList::_literal1<core::int>(2), core::_GrowableList::_literal1<core::int>(30))), 30);
self::expectEquals(self::test2(core::_GrowableList::_literal3<core::List<core::String>>(core::_GrowableList::_literal3<core::String>("foo", "bar", "baz"), core::_GrowableList::_literal3<core::String>("bar", "foo", "baz"), core::_GrowableList::_literal3<core::String>("bar", "baz", "foo"))), "foo");
self::expectEquals(self::test2(core::_GrowableList::•<core::List<core::String>>(0)), "");
self::expectThrows(() void => self::test3(core::_GrowableList::_literal1<dynamic>(core::_GrowableList::_literal3<core::int?>(null, 1, 2))));
self::expectEquals(self::test3(core::_GrowableList::•<dynamic>(0)), 1.{core::int::unary-}(){() core::int});
}
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 function to throw.";
}
}
constants {
#C1 = 1
}
Extra constant evaluation status:
Evaluated: InstanceInvocation @ org-dartlang-testcase:///simple_pattern_for_in.dart:7:10 -> IntConstant(-1)
Evaluated: InstanceInvocation @ org-dartlang-testcase:///simple_pattern_for_in.dart:23:10 -> IntConstant(-1)
Evaluated: InstanceInvocation @ org-dartlang-testcase:///simple_pattern_for_in.dart:27:40 -> IntConstant(-1)
Evaluated: InstanceInvocation @ org-dartlang-testcase:///simple_pattern_for_in.dart:32:27 -> IntConstant(-1)
Extra constant evaluation: evaluated: 190, effectively constant: 4