Created
July 23, 2012 10:28
-
-
Save andyli/3162981 to your computer and use it in GitHub Desktop.
fakeEnum
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @: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