You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-12 13:20:55 +00:00
GDScript: Fix issues with typed arrays
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
func test():
|
||||
var basic := [1]
|
||||
var typed: Array[int] = basic
|
||||
print('not ok')
|
||||
@@ -0,0 +1,6 @@
|
||||
GDTEST_RUNTIME_ERROR
|
||||
>> SCRIPT ERROR
|
||||
>> on function: test()
|
||||
>> runtime/errors/typed_array_assign_basic_to_typed.gd
|
||||
>> 3
|
||||
>> Trying to assign an array of type "Array" to a variable of type "Array[int]".
|
||||
@@ -0,0 +1,4 @@
|
||||
func test():
|
||||
var differently: Variant = [1.0] as Array[float]
|
||||
var typed: Array[int] = differently
|
||||
print('not ok')
|
||||
@@ -0,0 +1,6 @@
|
||||
GDTEST_RUNTIME_ERROR
|
||||
>> SCRIPT ERROR
|
||||
>> on function: test()
|
||||
>> runtime/errors/typed_array_assign_differently_typed.gd
|
||||
>> 3
|
||||
>> Trying to assign an array of type "Array[float]" to a variable of type "Array[int]".
|
||||
@@ -0,0 +1,7 @@
|
||||
func expect_typed(typed: Array[int]):
|
||||
print(typed.size())
|
||||
|
||||
func test():
|
||||
var basic := [1]
|
||||
expect_typed(basic)
|
||||
print('not ok')
|
||||
@@ -0,0 +1,6 @@
|
||||
GDTEST_RUNTIME_ERROR
|
||||
>> SCRIPT ERROR
|
||||
>> on function: test()
|
||||
>> runtime/errors/typed_array_pass_basic_to_typed.gd
|
||||
>> 6
|
||||
>> Invalid type in function 'expect_typed' in base 'RefCounted ()'. The array of argument 1 (Array) does not have the same element type as the expected typed array argument.
|
||||
@@ -0,0 +1,7 @@
|
||||
func expect_typed(typed: Array[int]):
|
||||
print(typed.size())
|
||||
|
||||
func test():
|
||||
var differently: Variant = [1.0] as Array[float]
|
||||
expect_typed(differently)
|
||||
print('not ok')
|
||||
@@ -0,0 +1,6 @@
|
||||
GDTEST_RUNTIME_ERROR
|
||||
>> SCRIPT ERROR
|
||||
>> on function: test()
|
||||
>> runtime/errors/typed_array_pass_differently_to_typed.gd
|
||||
>> 6
|
||||
>> Invalid type in function 'expect_typed' in base 'RefCounted ()'. The array of argument 1 (Array[float]) does not have the same element type as the expected typed array argument.
|
||||
@@ -0,0 +1,6 @@
|
||||
func test():
|
||||
var untyped: Variant = 32
|
||||
var typed: Array[int] = [untyped]
|
||||
assert(typed.get_typed_builtin() == TYPE_INT)
|
||||
assert(str(typed) == '[32]')
|
||||
print('ok')
|
||||
@@ -0,0 +1,2 @@
|
||||
GDTEST_OK
|
||||
ok
|
||||
Reference in New Issue
Block a user