~eda-qa/dhlib/main

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
class IntReconciled  extends haxe.unit.TestCase
{
	public function testTypeError() 
	{
		length = 3;
		aNumber = 5;
		assertEquals( 10, 2 * getFiveWorkaround() );
		assertEquals( 10, 2 * getFive() );
	}
	
	var aNumber : Null<Int>;
	var length : Int;
	
	function getFive() : Int
	{
		return aNumber != null ? maxi( aNumber, length ) : length;
	}
	
	function getFiveWorkaround() : Int
	{
		var a : Int = aNumber;
		if( aNumber != null )
			return maxi( a, length );
		return length;
	}
	
	//the inline here causes the exception in Flash9
	inline function maxi( a : Int, b : Int ) : Int
	{
		return a > b ? a : b;
	}
}