@@ -4,97 +4,106 @@ var custom_signal_emitted = null
44
55
66func _ready ():
7+ var example : Example = $ Example
8+
79 # Signal.
8- $ Example .emit_custom_signal ("Button" , 42 )
10+ example .emit_custom_signal ("Button" , 42 )
911 assert_equal (custom_signal_emitted , ["Button" , 42 ])
1012
1113 # To string.
12- assert_equal ($ Example .to_string (),'Example:[ GDExtension::Example <--> Instance ID:%s ]' % $ Example .get_instance_id ())
14+ assert_equal (example .to_string (),'Example:[ GDExtension::Example <--> Instance ID:%s ]' % example .get_instance_id ())
1315 # It appears there's a bug with instance ids :-(
1416 # assert_equal($Example/ExampleMin.to_string(), 'ExampleMin:[Wrapped:%s]' % $Example/ExampleMin.get_instance_id())
1517
1618 # Call static methods.
17- assert_equal ($ Example .test_static (9 , 100 ), 109 );
19+ assert_equal (Example .test_static (9 , 100 ), 109 );
1820 # It's void and static, so all we know is that it didn't crash.
19- $ Example .test_static2 ()
21+ Example .test_static2 ()
2022
2123 # Property list.
22- $ Example .property_from_list = Vector3 (100 , 200 , 300 )
23- assert_equal ($ Example .property_from_list , Vector3 (100 , 200 , 300 ))
24+ example .property_from_list = Vector3 (100 , 200 , 300 )
25+ assert_equal (example .property_from_list , Vector3 (100 , 200 , 300 ))
2426
2527 # Call simple methods.
26- $ Example .simple_func ()
28+ example .simple_func ()
2729 assert_equal (custom_signal_emitted , ['simple_func' , 3 ])
28- ( $ Example as Example ) .simple_const_func () # Force use of ptrcall
30+ example .simple_const_func ()
2931 assert_equal (custom_signal_emitted , ['simple_const_func' , 4 ])
3032
3133 # Pass custom reference.
32- assert_equal ($ Example .custom_ref_func (null ), - 1 )
34+ assert_equal (example .custom_ref_func (null ), - 1 )
3335 var ref1 = ExampleRef .new ()
3436 ref1 .id = 27
35- assert_equal ($ Example .custom_ref_func (ref1 ), 27 )
37+ assert_equal (example .custom_ref_func (ref1 ), 27 )
3638 ref1 .id += 1 ;
37- assert_equal ($ Example .custom_const_ref_func (ref1 ), 28 )
39+ assert_equal (example .custom_const_ref_func (ref1 ), 28 )
3840
3941 # Pass core reference.
40- assert_equal ($ Example .image_ref_func (null ), "invalid" )
41- assert_equal ($ Example .image_const_ref_func (null ), "invalid" )
42+ assert_equal (example .image_ref_func (null ), "invalid" )
43+ assert_equal (example .image_const_ref_func (null ), "invalid" )
4244 var image = Image .new ()
43- assert_equal ($ Example .image_ref_func (image ), "valid" )
44- assert_equal ($ Example .image_const_ref_func (image ), "valid" )
45+ assert_equal (example .image_ref_func (image ), "valid" )
46+ assert_equal (example .image_const_ref_func (image ), "valid" )
4547
4648 # Return values.
47- assert_equal ($ Example .return_something ("some string" ), "some string42" )
48- assert_equal ($ Example .return_something_const (), get_viewport ())
49- var null_ref = $ Example .return_empty_ref ()
49+ assert_equal (example .return_something ("some string" ), "some string42" )
50+ assert_equal (example .return_something_const (), get_viewport ())
51+ var null_ref = example .return_empty_ref ()
5052 assert_equal (null_ref , null )
51- var ret_ref = $ Example .return_extended_ref ()
53+ var ret_ref = example .return_extended_ref ()
5254 assert_not_equal (ret_ref .get_instance_id (), 0 )
5355 assert_equal (ret_ref .get_id (), 0 )
54- assert_equal ($ Example .get_v4 (), Vector4 (1.2 , 3.4 , 5.6 , 7.8 ))
55- assert_equal ($ Example .test_node_argument ($ Example ), $ Example )
56+ assert_equal (example .get_v4 (), Vector4 (1.2 , 3.4 , 5.6 , 7.8 ))
57+ assert_equal (example .test_node_argument (example ), example )
5658
5759 # VarArg method calls.
5860 var var_ref = ExampleRef .new ()
59- assert_not_equal ($ Example .extended_ref_checks (var_ref ).get_instance_id (), var_ref .get_instance_id ())
60- assert_equal ($ Example .varargs_func ("some" , "arguments" , "to" , "test" ), 4 )
61- assert_equal ($ Example .varargs_func_nv ("some" , "arguments" , "to" , "test" ), 46 )
62- $ Example .varargs_func_void ("some" , "arguments" , "to" , "test" )
61+ assert_not_equal (example .extended_ref_checks (var_ref ).get_instance_id (), var_ref .get_instance_id ())
62+ assert_equal (example .varargs_func ("some" , "arguments" , "to" , "test" ), 4 )
63+ assert_equal (example .varargs_func_nv ("some" , "arguments" , "to" , "test" ), 46 )
64+ example .varargs_func_void ("some" , "arguments" , "to" , "test" )
6365 assert_equal (custom_signal_emitted , ["varargs_func_void" , 5 ])
6466
6567 # Method calls with default values.
66- assert_equal ($ Example .def_args (), 300 )
67- assert_equal ($ Example .def_args (50 ), 250 )
68- assert_equal ($ Example .def_args (50 , 100 ), 150 )
68+ assert_equal (example .def_args (), 300 )
69+ assert_equal (example .def_args (50 ), 250 )
70+ assert_equal (example .def_args (50 , 100 ), 150 )
6971
7072 # Array and Dictionary
71- assert_equal ($ Example .test_array (), [1 , 2 ])
72- assert_equal ($ Example .test_tarray (), [ Vector2 (1 , 2 ), Vector2 (2 , 3 ) ])
73- assert_equal ($ Example .test_dictionary (), {"hello" : "world" , "foo" : "bar" })
73+ assert_equal (example .test_array (), [1 , 2 ])
74+ assert_equal (example .test_tarray (), [ Vector2 (1 , 2 ), Vector2 (2 , 3 ) ])
75+ assert_equal (example .test_dictionary (), {"hello" : "world" , "foo" : "bar" })
7476 var array : Array [int ] = [1 , 2 , 3 ]
75- assert_equal ($ Example .test_tarray_arg (array ), 6 )
77+ assert_equal (example .test_tarray_arg (array ), 6 )
7678
7779 # String += operator
78- assert_equal ($ Example .test_string_ops (), "ABCĎE" )
80+ assert_equal (example .test_string_ops (), "ABCĎE" )
7981
8082 # PackedArray iterators
81- assert_equal ($ Example .test_vector_ops (), 105 )
83+ assert_equal (example .test_vector_ops (), 105 )
8284
8385 # Properties.
84- assert_equal ($ Example .group_subgroup_custom_position , Vector2 (0 , 0 ))
85- $ Example .group_subgroup_custom_position = Vector2 (50 , 50 )
86- assert_equal ($ Example .group_subgroup_custom_position , Vector2 (50 , 50 ))
86+ assert_equal (example .group_subgroup_custom_position , Vector2 (0 , 0 ))
87+ example .group_subgroup_custom_position = Vector2 (50 , 50 )
88+ assert_equal (example .group_subgroup_custom_position , Vector2 (50 , 50 ))
8789
8890 # Constants.
89- assert_equal ($ Example .FIRST , 0 )
90- assert_equal ($ Example .ANSWER_TO_EVERYTHING , 42 )
91- assert_equal ($ Example .CONSTANT_WITHOUT_ENUM , 314 )
91+ assert_equal (Example .FIRST , 0 )
92+ assert_equal (Example .ANSWER_TO_EVERYTHING , 42 )
93+ assert_equal (Example .CONSTANT_WITHOUT_ENUM , 314 )
9294
9395 # BitFields.
9496 assert_equal (Example .FLAG_ONE , 1 )
9597 assert_equal (Example .FLAG_TWO , 2 )
96- assert_equal ($ Example .test_bitfield (0 ), 0 )
97- assert_equal ($ Example .test_bitfield (Example .FLAG_ONE | Example .FLAG_TWO ), 3 )
98+ assert_equal (example .test_bitfield (0 ), 0 )
99+ assert_equal (example .test_bitfield (Example .FLAG_ONE | Example .FLAG_TWO ), 3 )
100+
101+ # Virtual method.
102+ var event = InputEventKey .new ()
103+ event .key_label = KEY_H
104+ event .unicode = 72
105+ get_viewport ().push_input (event )
106+ assert_equal (custom_signal_emitted , ["_input: H" , 72 ])
98107
99108 exit_with_status ()
100109
0 commit comments