Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/usr.bin/indent tests/indent: migrate tests for unary a...
details: https://anonhg.NetBSD.org/src/rev/86b3d30bbdb1
branches: trunk
changeset: 365753:86b3d30bbdb1
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Apr 23 09:35:26 2022 +0000
description:
tests/indent: migrate tests for unary and binary operators
diffstat:
tests/usr.bin/indent/lsym_binary_op.c | 39 +++++++++++++-
tests/usr.bin/indent/lsym_unary_op.c | 9 ++-
tests/usr.bin/indent/token_binary_op.c | 90 +---------------------------------
3 files changed, 45 insertions(+), 93 deletions(-)
diffs (187 lines):
diff -r b577ff125428 -r 86b3d30bbdb1 tests/usr.bin/indent/lsym_binary_op.c
--- a/tests/usr.bin/indent/lsym_binary_op.c Sat Apr 23 09:01:03 2022 +0000
+++ b/tests/usr.bin/indent/lsym_binary_op.c Sat Apr 23 09:35:26 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_binary_op.c,v 1.3 2022/04/22 21:21:20 rillig Exp $ */
+/* $NetBSD: lsym_binary_op.c,v 1.4 2022/04/23 09:35:26 rillig Exp $ */
/*
* Tests for the token lsym_binary_op, which represents a binary operator in
@@ -22,7 +22,42 @@
*/
#indent input
-// TODO: add input
+void
+binary_operators(void)
+{
+ /* In the order of appearance in C11 6.5. */
+ a = a * a;
+ a = a / a;
+ a = a % a;
+ a = a + a;
+ a = a - a;
+ a = a << a;
+ a = a >> a;
+ a = a < a;
+ a = a > a;
+ a = a <= a;
+ a = a >= a;
+ a = a == a;
+ a = a != a;
+ a = a & a;
+ a = a ^ a;
+ a = a | a;
+ a = a && a;
+ a = a || a;
+ a = a ? a : a;
+ a = a;
+ a *= a;
+ a /= a;
+ a %= a;
+ a += a;
+ a -= a;
+ a <<= a;
+ a >>= a;
+ a &= a;
+ a ^= a;
+ a |= a;
+ a = a, a;
+}
#indent end
#indent run-equals-input
diff -r b577ff125428 -r 86b3d30bbdb1 tests/usr.bin/indent/lsym_unary_op.c
--- a/tests/usr.bin/indent/lsym_unary_op.c Sat Apr 23 09:01:03 2022 +0000
+++ b/tests/usr.bin/indent/lsym_unary_op.c Sat Apr 23 09:35:26 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_unary_op.c,v 1.2 2022/04/22 21:21:20 rillig Exp $ */
+/* $NetBSD: lsym_unary_op.c,v 1.3 2022/04/23 09:35:26 rillig Exp $ */
/*
* Tests for the token lsym_unary_op, which represents a unary operator.
@@ -11,7 +11,12 @@
*/
#indent input
-// TODO: add input
+void
+unary_operators(void)
+{
+ /* In the order of appearance in C11 6.5. */
+ function(a++, a--, ++a, --a, &a, *a, +a, -a, ~a, !a);
+}
#indent end
#indent run-equals-input
diff -r b577ff125428 -r 86b3d30bbdb1 tests/usr.bin/indent/token_binary_op.c
--- a/tests/usr.bin/indent/token_binary_op.c Sat Apr 23 09:01:03 2022 +0000
+++ b/tests/usr.bin/indent/token_binary_op.c Sat Apr 23 09:35:26 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: token_binary_op.c,v 1.10 2022/04/22 21:21:20 rillig Exp $ */
+/* $NetBSD: token_binary_op.c,v 1.11 2022/04/23 09:35:26 rillig Exp $ */
/*
* Tests for binary operators like '+', '&&' and several others.
@@ -21,50 +21,6 @@
int period = structure.member;
int arrow = structure->member;
- ++prefix_increment;
- postfix_increment++;
- --prefix_decrement;
- postfix_decrement--;
- int *address = &lvalue;
- int bitwise_and = value & mask;
- int product = factor * factor;
- int dereferenced = *address;
- int positive = +number;
- int sum = number + number;
- int negative = -number;
- int difference = number - number;
- bool negated = !condition;
-
- int quotient = number / number;
- int modulo = number % number;
- int shifted_left = number << number;
- int shifted_right = number >> number;
- bool less_than = number < number;
- bool greater_than = number > number;
- bool less_equal = number <= number;
- bool greater_equal = number >= number;
- bool equal = number == number;
- bool unequal = number != number;
- int bitwise_exclusive_or = number ^ number;
- int bitwise_or = number | number;
- bool logical_and = condition && condition;
- bool logical_or = condition || condition;
-
- int conditional = condition ? number : number;
-
- /* combined assignment operators */
- number = (expression);
- number *= number;
- number /= number;
- number %= number;
- number += number;
- number -= number;
- number <<= number;
- number >>= number;
- number &= number;
- number ^= number;
- number |= number;
-
number = function(argument1, argument2);
number = function(argument), number;
@@ -85,50 +41,6 @@
int period = structure.member;
int arrow = structure->member;
- ++prefix_increment;
- postfix_increment++;
- --prefix_decrement;
- postfix_decrement--;
- int *address = &lvalue;
- int bitwise_and = value & mask;
- int product = factor * factor;
- int dereferenced = *address;
- int positive = +number;
- int sum = number + number;
- int negative = -number;
- int difference = number - number;
- bool negated = !condition;
-
- int quotient = number / number;
- int modulo = number % number;
- int shifted_left = number << number;
- int shifted_right = number >> number;
- bool less_than = number < number;
- bool greater_than = number > number;
- bool less_equal = number <= number;
- bool greater_equal = number >= number;
- bool equal = number == number;
- bool unequal = number != number;
- int bitwise_exclusive_or = number ^ number;
- int bitwise_or = number | number;
- bool logical_and = condition && condition;
- bool logical_or = condition || condition;
-
- int conditional = condition ? number : number;
-
- /* combined assignment operators */
- number = (expression);
- number *= number;
- number /= number;
- number %= number;
- number += number;
- number -= number;
- number <<= number;
- number >>= number;
- number &= number;
- number ^= number;
- number |= number;
-
number = function(argument1, argument2);
number = function(argument), number;
Home |
Main Index |
Thread Index |
Old Index