blob: 55327dd767f1f2eb5f9725ef3afd6da870f6b1e9 [file] [log] [blame] [edit]
library;
import self as self;
import "dart:core" as core;
class A extends core::Object {
synthetic constructor •() self::A
: super core::Object::•()
;
static get foo() core::String
return "A.foo";
static set baz(core::num value) void {
throw "A.baz=";
}
}
extension E on self::A {
static get foo = get self::E|foo;
static get bar = get self::E|bar;
static set baz = set self::E|baz;
static set quux = set self::E|quux;
}
static extension-member get E|foo() core::String
return "E.foo";
static extension-member get E|bar() core::String
return "E.bar";
static extension-member set E|baz(core::num value) void {}
static extension-member set E|quux(core::bool value) void {}
static method main() dynamic {
self::expectEqual(self::A::foo, "A.foo");
self::expectEqual(self::E|bar, "E.bar");
self::expectThrows(() Null {
self::A::baz = 0;
});
self::expectDoesntThrow(() Null {
self::E|quux = false;
});
}
static method expectEqual(dynamic a, dynamic b) dynamic {
if(!(a =={core::Object::==}{(core::Object) core::bool} b)) {
throw "Expected the values to be equal.";
}
}
static method expectThrows(() dynamic f) dynamic {
core::bool hasThrown = false;
try {
f(){() dynamic};
}
on dynamic catch(no-exception-var) {
hasThrown = true;
}
if(!hasThrown) {
throw "Expected the function to throw an exception.";
}
}
static method expectDoesntThrow(() dynamic f) dynamic {
core::bool hasThrown = true;
try {
f(){() dynamic};
hasThrown = false;
}
on dynamic catch(no-exception-var) {
}
if(hasThrown) {
throw "Expected the function not to throw exceptions.";
}
}