Implement typed dictionaries
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
func test():
|
||||
var basic := { 1: 1 }
|
||||
var typed: Dictionary[int, int] = basic
|
||||
print('not ok')
|
||||
@@ -0,0 +1,6 @@
|
||||
GDTEST_RUNTIME_ERROR
|
||||
>> SCRIPT ERROR
|
||||
>> on function: test()
|
||||
>> runtime/errors/typed_dictionary_assign_basic_to_typed.gd
|
||||
>> 3
|
||||
>> Trying to assign a dictionary of type "Dictionary" to a variable of type "Dictionary[int, int]".
|
||||
@@ -0,0 +1,4 @@
|
||||
func test():
|
||||
var differently: Variant = { 1.0: 0.0 } as Dictionary[float, float]
|
||||
var typed: Dictionary[int, int] = differently
|
||||
print('not ok')
|
||||
@@ -0,0 +1,6 @@
|
||||
GDTEST_RUNTIME_ERROR
|
||||
>> SCRIPT ERROR
|
||||
>> on function: test()
|
||||
>> runtime/errors/typed_dictionary_assign_differently_typed.gd
|
||||
>> 3
|
||||
>> Trying to assign a dictionary of type "Dictionary[float, float]" to a variable of type "Dictionary[int, int]".
|
||||
@@ -0,0 +1,7 @@
|
||||
class Foo: pass
|
||||
class Bar extends Foo: pass
|
||||
class Baz extends Foo: pass
|
||||
|
||||
func test():
|
||||
var typed: Dictionary[Bar, Bar] = { Baz.new() as Foo: Baz.new() as Foo }
|
||||
print('not ok')
|
||||
@@ -0,0 +1,5 @@
|
||||
GDTEST_RUNTIME_ERROR
|
||||
>> ERROR
|
||||
>> Method/function failed.
|
||||
>> Unable to convert key from "Object" to "Object".
|
||||
not ok
|
||||
@@ -0,0 +1,7 @@
|
||||
func expect_typed(typed: Dictionary[int, int]):
|
||||
print(typed.size())
|
||||
|
||||
func test():
|
||||
var basic := { 1: 1 }
|
||||
expect_typed(basic)
|
||||
print('not ok')
|
||||
@@ -0,0 +1,6 @@
|
||||
GDTEST_RUNTIME_ERROR
|
||||
>> SCRIPT ERROR
|
||||
>> on function: test()
|
||||
>> runtime/errors/typed_dictionary_pass_basic_to_typed.gd
|
||||
>> 6
|
||||
>> Invalid type in function 'expect_typed' in base 'RefCounted (typed_dictionary_pass_basic_to_typed.gd)'. The dictionary of argument 1 (Dictionary) does not have the same element type as the expected typed dictionary argument.
|
||||
@@ -0,0 +1,7 @@
|
||||
func expect_typed(typed: Dictionary[int, int]):
|
||||
print(typed.size())
|
||||
|
||||
func test():
|
||||
var differently: Variant = { 1.0: 0.0 } as Dictionary[float, float]
|
||||
expect_typed(differently)
|
||||
print('not ok')
|
||||
@@ -0,0 +1,6 @@
|
||||
GDTEST_RUNTIME_ERROR
|
||||
>> SCRIPT ERROR
|
||||
>> on function: test()
|
||||
>> runtime/errors/typed_dictionary_pass_differently_to_typed.gd
|
||||
>> 6
|
||||
>> Invalid type in function 'expect_typed' in base 'RefCounted (typed_dictionary_pass_differently_to_typed.gd)'. The dictionary of argument 1 (Dictionary[float, float]) does not have the same element type as the expected typed dictionary argument.
|
||||
Reference in New Issue
Block a user