[vala/0.42] tests: Extend assignment and array element access tests
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.42] tests: Extend assignment and array element access tests
- Date: Mon, 26 Nov 2018 09:15:14 +0000 (UTC)
commit 10d5363de9e85d6ce81909d7d82e1d220b9037e6
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Thu Nov 22 10:36:47 2018 +0100
tests: Extend assignment and array element access tests
tests/basic-types/arrays.vala | 13 +++++++++++++
tests/basic-types/integers.vala | 20 ++++++++++++++++++++
2 files changed, 33 insertions(+)
---
diff --git a/tests/basic-types/arrays.vala b/tests/basic-types/arrays.vala
index 085f22f06..cbbdc6ef0 100644
--- a/tests/basic-types/arrays.vala
+++ b/tests/basic-types/arrays.vala
@@ -48,6 +48,19 @@ void test_integer_array () {
d[1] = null;
assert (d[0] == 10);
assert (d[1] == null);
+
+ // element assignment
+ int[] e = { 13, 47 };
+ e[0] = 96;
+ assert (e[0] == 96);
+ e[0] /= 24;
+ assert (e[0] == 4);
+ e[0] += 2;
+ assert (e[0] == 6);
+ e[0] *= 4;
+ assert (e[0] == 24);
+ e[0] -= 23;
+ assert (e[0] == 1);
}
void test_string_array () {
diff --git a/tests/basic-types/integers.vala b/tests/basic-types/integers.vala
index 4b097ae2e..90618351d 100644
--- a/tests/basic-types/integers.vala
+++ b/tests/basic-types/integers.vala
@@ -16,42 +16,62 @@ void test_int () {
// +
i = 42 + 23;
assert (i == 65);
+ i += 7;
+ assert (i == 72);
// -
i = 42 - 23;
assert (i == 19);
+ i -= 7;
+ assert (i == 12);
// *
i = 42 * 23;
assert (i == 966);
+ i *= 7;
+ assert (i == 6762);
// /
i = 42 / 23;
assert (i == 1);
+ i /= 1;
+ assert (i == 1);
// %
i = 42 % 23;
assert (i == 19);
+ i %= 7;
+ assert (i == 5);
// <<
i = 42 << 3;
assert (i == 336);
+ i <<= 7;
+ assert (i == 43008);
// >>
i = 42 >> 3;
assert (i == 5);
+ i >>= 2;
+ assert (i == 1);
// &
i = 42 & 23;
assert (i == 2);
+ i &= 1;
+ assert (i == 0);
// |
i = 42 | 23;
assert (i == 63);
+ i |= 128;
+ assert (i == 191);
// ^
i = 42 ^ 23;
assert (i == 61);
+ i ^= 23;
+ assert (i == 42);
// equality and relational
i = 42;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]