diff options
author | Rico Tzschichholz <ricotz@ubuntu.com> | 2022-11-21 10:55:44 +0100 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2022-12-08 15:37:08 +0100 |
commit | 865733142cad7f44f1c41a3e4bcd043048a3c756 (patch) | |
tree | e35043cab381c99ff339d4097ddc4b4ac07f7c3f /tests | |
parent | 546567e487bd503d9c4bb2c5a1543fcc871740fe (diff) | |
download | vala-865733142cad7f44f1c41a3e4bcd043048a3c756.tar.gz |
vala: Improve integer literal checks
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 3 | ||||
-rw-r--r-- | tests/basic-types/integer-literals.c-expected | 6 | ||||
-rw-r--r-- | tests/basic-types/integer-literals.vala | 4 | ||||
-rw-r--r-- | tests/basic-types/integer-signed-erange.test | 5 | ||||
-rw-r--r-- | tests/basic-types/integer-unsigned-erange.test | 5 | ||||
-rw-r--r-- | tests/basic-types/integer-unsigned-invalid.test | 5 |
6 files changed, 28 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 4536dcb3b..458e56bd1 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -42,6 +42,9 @@ AM_TESTS_ENVIRONMENT = \ TESTS = \ basic-types/gassert.vala \ basic-types/integer-literals.vala \ + basic-types/integer-signed-erange.test \ + basic-types/integer-unsigned-erange.test \ + basic-types/integer-unsigned-invalid.test \ basic-types/integers.vala \ basic-types/integers-boxed-cast.vala \ basic-types/escape-chars.vala \ diff --git a/tests/basic-types/integer-literals.c-expected b/tests/basic-types/integer-literals.c-expected index c534fbe7f..3a162e1b7 100644 --- a/tests/basic-types/integer-literals.c-expected +++ b/tests/basic-types/integer-literals.c-expected @@ -44,6 +44,12 @@ _vala_main (void) foo = 23LL; bar = 42LL; } + { + guint64 foo = 0ULL; + gint64 bar = 0LL; + foo = 18446744073709551615ULL; + bar = -9223372036854775808LL; + } } int diff --git a/tests/basic-types/integer-literals.vala b/tests/basic-types/integer-literals.vala index 60deedbd8..0f9d4106b 100644 --- a/tests/basic-types/integer-literals.vala +++ b/tests/basic-types/integer-literals.vala @@ -23,4 +23,8 @@ void main () { int64 foo = 23LL; int64 bar = 42ll; } + { + uint64 foo = 18446744073709551615; + int64 bar = -9223372036854775808; + } } diff --git a/tests/basic-types/integer-signed-erange.test b/tests/basic-types/integer-signed-erange.test new file mode 100644 index 000000000..2e4042064 --- /dev/null +++ b/tests/basic-types/integer-signed-erange.test @@ -0,0 +1,5 @@ +Invalid Code + +void main () { + int64 foo = -9223372036854775809; +} diff --git a/tests/basic-types/integer-unsigned-erange.test b/tests/basic-types/integer-unsigned-erange.test new file mode 100644 index 000000000..64ada00ff --- /dev/null +++ b/tests/basic-types/integer-unsigned-erange.test @@ -0,0 +1,5 @@ +Invalid Code + +void main () { + uint64 foo = 18446744073709551616; +} diff --git a/tests/basic-types/integer-unsigned-invalid.test b/tests/basic-types/integer-unsigned-invalid.test new file mode 100644 index 000000000..c8b3d96bd --- /dev/null +++ b/tests/basic-types/integer-unsigned-invalid.test @@ -0,0 +1,5 @@ +Invalid Code + +void main () { + uint foo = -23U; +} |