| library test; |
| import self as self; |
| import "dart:core" as core; |
| |
| static method block_test() → void { |
| () →* core::List<core::Object*>* g; |
| g = () → core::List<core::Object*>* { |
| return core::_GrowableList::_literal1<core::Object*>(3); |
| }; |
| assert(g is () →* core::List<core::Object*>*); |
| assert(!(g is () →* core::List<core::int*>*)); |
| g(){() →* core::List<core::Object*>*}.{core::List::add}("hello"){(core::Object*) →* void}; |
| core::List<core::int*>* l = core::_GrowableList::_literal1<core::int*>(3); |
| g = () → core::List<core::int*>* { |
| return l; |
| }; |
| assert(g is () →* core::List<core::Object*>*); |
| assert(g is () →* core::List<core::int*>*); |
| try { |
| g(){() →* core::List<core::Object*>*}.{core::List::add}("hello"){(core::Object*) →* void}; |
| throw "expected a runtime error"; |
| } |
| on core::TypeError* catch(no-exception-var) { |
| } |
| core::Object* o = l; |
| g = () → core::List<core::Object*>* { |
| return o as{TypeError} core::List<core::Object*>*; |
| }; |
| assert(g is () →* core::List<core::Object*>*); |
| assert(!(g is () →* core::List<core::int*>*)); |
| assert(!(g is () →* core::Object*)); |
| g(){() →* core::List<core::Object*>*}; |
| o = 3; |
| try { |
| g(){() →* core::List<core::Object*>*}; |
| throw "expected a runtime error"; |
| } |
| on core::TypeError* catch(no-exception-var) { |
| } |
| } |
| static method arrow_test() → void { |
| () →* core::List<core::Object*>* g; |
| g = () → core::List<core::Object*>* => core::_GrowableList::_literal1<core::Object*>(3); |
| assert(g is () →* core::List<core::Object*>*); |
| assert(!(g is () →* core::List<core::int*>*)); |
| g(){() →* core::List<core::Object*>*}.{core::List::add}("hello"){(core::Object*) →* void}; |
| core::List<core::int*>* l = core::_GrowableList::_literal1<core::int*>(3); |
| g = () → core::List<core::int*>* => l; |
| assert(g is () →* core::List<core::Object*>*); |
| assert(g is () →* core::List<core::int*>*); |
| try { |
| g(){() →* core::List<core::Object*>*}.{core::List::add}("hello"){(core::Object*) →* void}; |
| throw "expected a runtime error"; |
| } |
| on core::TypeError* catch(no-exception-var) { |
| } |
| core::Object* o = l; |
| g = () → core::List<core::Object*>* => o as{TypeError} core::List<core::Object*>*; |
| assert(g is () →* core::List<core::Object*>*); |
| assert(!(g is () →* core::List<core::int*>*)); |
| assert(!(g is () →* core::Object*)); |
| g(){() →* core::List<core::Object*>*}; |
| o = 3; |
| try { |
| g(){() →* core::List<core::Object*>*}; |
| throw "expected a runtime error"; |
| } |
| on core::TypeError* catch(no-exception-var) { |
| } |
| } |
| static method main() → dynamic { |
| self::block_test(); |
| self::arrow_test(); |
| } |