Skip to content

Instantly share code, notes, and snippets.

@andyli
Created July 23, 2012 10:28
Show Gist options
  • Select an option

  • Save andyli/3162981 to your computer and use it in GitHub Desktop.

Select an option

Save andyli/3162981 to your computer and use it in GitHub Desktop.
fakeEnum
@:fakeEnum(String)
extern enum StageAlign {
BOTTOM;
}
@:native ("StageAlign")
class StageAlign_impl {
static public var BOTTOM = "_bottom_";
}
class Test extends haxe.unit.TestCase {
public function testSwitch():Void {
var i = BOTTOM;
assertTrue(switch(i){ case BOTTOM: true; default: false; });
}
public function testUntyped():Void {
var i = BOTTOM;
assertEquals("_bottom_", untyped BOTTOM);
}
public function testCast():Void {
var i = BOTTOM;
assertEquals("_bottom_", cast BOTTOM);
}
static function main():Void {
var runner = new haxe.unit.TestRunner();
runner.add(new Test());
runner.run();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment