~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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* <license>
 * This file is part of the dis-Emi-A HaXe Library. Copyright © edA-qa mort-ora-y
 * For full copyright and license information please refer to doc/license.txt.
 * </license> 
 */
interface BasicType
{
}

class StaticTypeA implements BasicType
{
	public var a : Int;

	public function new()
	{
	}
}

class StaticTypeB implements BasicType
{
	public var b : Int;

	public function new()
	{
	}
}

class DynamicFields extends haxe.unit.TestCase
{
	public function testAdd() 
	{
		var o = new StaticTypeA();
		o.a = 10;
		addValue( o, 17 );
		assertEquals( 17, getValue(o) );
		assertEquals( 10, o.a );
		assertTrue( Std.is( o, StaticTypeA ) );
		assertTrue( Std.is( o, BasicType ) );
	}
	
	function addValue( b : BasicType, value : Int )
	{
		untyped b.__dfValue = value;
	}
	
	function getValue( b : BasicType ) : Int
	{
		return untyped b.__dfValue;
	}
}