GDScript: Fix test for read-only state of constants

This commit is contained in:
Dmitrii Maganov
2023-01-22 11:07:48 +02:00
parent d1e5903c67
commit abe6d67232
14 changed files with 43 additions and 52 deletions

View File

@ -1,4 +0,0 @@
const array: Array = [0]
func test():
array.push_back(0)

View File

@ -1,7 +0,0 @@
GDTEST_RUNTIME_ERROR
>> ERROR
>> on function: push_back()
>> core/variant/array.cpp
>> 253
>> Condition "_p->read_only" is true.
>> Array is in read-only state.

View File

@ -1,4 +0,0 @@
const dictionary := {}
func test():
dictionary.erase(0)

View File

@ -1,7 +0,0 @@
GDTEST_RUNTIME_ERROR
>> ERROR
>> on function: erase()
>> core/variant/dictionary.cpp
>> 177
>> Condition "_p->read_only" is true. Returning: false
>> Dictionary is in read-only state.

View File

@ -0,0 +1,10 @@
const array: Array = [0]
const dictionary := {1: 2}
@warning_ignore("assert_always_true")
func test():
assert(array.is_read_only() == true)
assert(str(array) == '[0]')
assert(dictionary.is_read_only() == true)
assert(str(dictionary) == '{ 1: 2 }')
print('ok')

View File

@ -0,0 +1,2 @@
GDTEST_OK
ok