@@ -19,6 +19,8 @@ func _ready():
19
19
"test" : "1.0" ,
20
20
"coolness" : true ,
21
21
Vector2 .ZERO : 5 ,
22
+ "dumbness" : null ,
23
+ "float" : 5.0 ,
22
24
}
23
25
24
26
StagTest .assert_equal (1.0 , StagUtils .default (d , "test" , TYPE_FLOAT ), "invalid types should be converted when possible" )
@@ -27,5 +29,16 @@ func _ready():
27
29
StagTest .assert_equal (5 , StagUtils .default (d , Vector2 .ZERO , TYPE_INT ), "non-string keys can be used" )
28
30
StagTest .assert_equal (false , StagUtils .default (d , "deer" , TYPE_BOOL ), "non-existent keys use the corresponding type fallback" )
29
31
StagTest .assert_equal (true , StagUtils .default (d , "deer" , TYPE_BOOL , true ), "non-existent keys use overrides when provided" )
30
- StagTest .assert_equal ("" , StagUtils .default (d , "deer" , TYPE_STRING ), "non-existent keys keep empty strings" )
31
- StagTest .assert_true (typeof (& "" ) == typeof (StagUtils .default (d , "deer" , TYPE_STRING_NAME )), "should retain proper type when loading default" )
32
+ StagTest .assert_equal ("" , StagUtils .default (d , "deer" , TYPE_STRING ), "non-existent keys return empty strings" )
33
+ StagTest .assert_true (typeof (& "" ) == typeof (StagUtils .default (d , "deer" , TYPE_STRING_NAME )),
34
+ "should retain proper type when loading default" )
35
+
36
+ StagTest .assert_equal ("" , StagUtils .default (d , "dumbness" , TYPE_STRING ),
37
+ "fetched null values are returned as empty strings" )
38
+ StagTest .assert_equal (& "" , StagUtils .default (d , "dumbness" , TYPE_STRING_NAME ),
39
+ "fetched null values are returned as empty string names" )
40
+
41
+ StagTest .assert_equal (5 , StagUtils .default (d , "float" , TYPE_INT , 1 ),
42
+ "numbers within reason are converted" )
43
+ StagTest .assert_equal (1 , StagUtils .default (d , "float" , TYPE_INT , 1 , false ),
44
+ "numbers within reason are not converted without salvage" )
0 commit comments