summaryrefslogtreecommitdiff
path: root/modules/gdscript/tests
diff options
context:
space:
mode:
authorDmitrii Maganov <vonagam@gmail.com>2023-01-22 11:07:48 +0200
committerDmitrii Maganov <vonagam@gmail.com>2023-01-27 05:28:08 +0200
commitabe6d6723219b592829fd9ba2a2c78950c83d64e (patch)
tree374101c2ae82959906d06c6a573d6cc63f5b0151 /modules/gdscript/tests
parentd1e5903c67956707948b1de370b807e3aad395b7 (diff)
GDScript: Fix test for read-only state of constants
Diffstat (limited to 'modules/gdscript/tests')
-rw-r--r--modules/gdscript/tests/scripts/runtime/errors/constant_array_push_back.gd4
-rw-r--r--modules/gdscript/tests/scripts/runtime/errors/constant_array_push_back.out7
-rw-r--r--modules/gdscript/tests/scripts/runtime/errors/constant_dictionary_erase.gd4
-rw-r--r--modules/gdscript/tests/scripts/runtime/errors/constant_dictionary_erase.out7
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/constants_are_read_only.gd10
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/constants_are_read_only.out2
6 files changed, 12 insertions, 22 deletions
diff --git a/modules/gdscript/tests/scripts/runtime/errors/constant_array_push_back.gd b/modules/gdscript/tests/scripts/runtime/errors/constant_array_push_back.gd
deleted file mode 100644
index 3e71cd0518..0000000000
--- a/modules/gdscript/tests/scripts/runtime/errors/constant_array_push_back.gd
+++ /dev/null
@@ -1,4 +0,0 @@
-const array: Array = [0]
-
-func test():
- array.push_back(0)
diff --git a/modules/gdscript/tests/scripts/runtime/errors/constant_array_push_back.out b/modules/gdscript/tests/scripts/runtime/errors/constant_array_push_back.out
deleted file mode 100644
index ba3e1c46c6..0000000000
--- a/modules/gdscript/tests/scripts/runtime/errors/constant_array_push_back.out
+++ /dev/null
@@ -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.
diff --git a/modules/gdscript/tests/scripts/runtime/errors/constant_dictionary_erase.gd b/modules/gdscript/tests/scripts/runtime/errors/constant_dictionary_erase.gd
deleted file mode 100644
index 7b350e81ad..0000000000
--- a/modules/gdscript/tests/scripts/runtime/errors/constant_dictionary_erase.gd
+++ /dev/null
@@ -1,4 +0,0 @@
-const dictionary := {}
-
-func test():
- dictionary.erase(0)
diff --git a/modules/gdscript/tests/scripts/runtime/errors/constant_dictionary_erase.out b/modules/gdscript/tests/scripts/runtime/errors/constant_dictionary_erase.out
deleted file mode 100644
index 3e7ca11a4f..0000000000
--- a/modules/gdscript/tests/scripts/runtime/errors/constant_dictionary_erase.out
+++ /dev/null
@@ -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.
diff --git a/modules/gdscript/tests/scripts/runtime/features/constants_are_read_only.gd b/modules/gdscript/tests/scripts/runtime/features/constants_are_read_only.gd
new file mode 100644
index 0000000000..d1746979be
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/constants_are_read_only.gd
@@ -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')
diff --git a/modules/gdscript/tests/scripts/runtime/features/constants_are_read_only.out b/modules/gdscript/tests/scripts/runtime/features/constants_are_read_only.out
new file mode 100644
index 0000000000..1b47ed10dc
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/constants_are_read_only.out
@@ -0,0 +1,2 @@
+GDTEST_OK
+ok