-
-
Notifications
You must be signed in to change notification settings - Fork 671
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for toString of nullable abstract
- Loading branch information
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package unit.issues; | ||
|
||
private abstract MyStringA(Null<String>) from Null<String> { | ||
function toString() { | ||
if (this == null) | ||
return "EMPTY"; | ||
return this; | ||
} | ||
} | ||
|
||
private typedef NullableString = Null<String>; | ||
|
||
private abstract MyStringB(NullableString) from NullableString { | ||
function toString() { | ||
if (this == null) | ||
return "EMPTY"; | ||
return this; | ||
} | ||
} | ||
|
||
class Issue12019 extends unit.Test { | ||
final a:MyStringA = null; | ||
final b:MyStringB = null; | ||
|
||
var oldTrace:(Dynamic, ?Null<haxe.PosInfos>) -> Void; | ||
|
||
function setup() { | ||
oldTrace = haxe.Log.trace; | ||
} | ||
|
||
function teardown() { | ||
haxe.Log.trace = oldTrace; | ||
} | ||
|
||
function testTrace() { | ||
haxe.Log.trace = function(v, ?infos) { | ||
eq("EMPTY", v); | ||
}; | ||
|
||
trace(a); | ||
trace(b); | ||
} | ||
|
||
function testConcatenate() { | ||
eq("Concatenated: EMPTY", "Concatenated: " + a); | ||
eq("Concatenated: EMPTY", "Concatenated: " + b); | ||
} | ||
} |