aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.rust/expr.exp
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-04-22 07:16:36 -0600
committerTom Tromey <tom@tromey.com>2021-04-22 07:16:36 -0600
commit22f80c0f77be6304b9632827d8161e28cb4a195a (patch)
tree15a04368f45009943a10d976eb442c761c257dc6 /gdb/testsuite/gdb.rust/expr.exp
parentb11b2969a9a507d9e42c8029cfeb06b9bc41fceb (diff)
downloadgdb-22f80c0f77be6304b9632827d8161e28cb4a195a.zip
gdb-22f80c0f77be6304b9632827d8161e28cb4a195a.tar.gz
gdb-22f80c0f77be6304b9632827d8161e28cb4a195a.tar.bz2
Improve code coverage of Rust testing
I enabled code coverage and ran the gdb test suite, and noticed that the new Rust parser was missing testing on a few lines that were easy to cover. This patch mostly adds tests for certain syntax errors; but this process also uncovered a couple of real bugs: I must have cut-and-pasted the 'sizeof' parsing code from some other code, because it is checking for KW_MUT (the old bison parser did not do this), and the array length check is actually impossible because a negative number like '-1' is parsed as two tokens. gdb/ChangeLog 2021-04-22 Tom Tromey <tom@tromey.com> * rust-parse.c (rust_parser::parse_sizeof): Remove KW_MUT code. (struct typed_val_int) <val>: Now ULONGEST. (rust_parser::parse_array_type): Remove negative check. (rust_lex_int_test): Change 'value' to ULONGEST. gdb/testsuite/ChangeLog 2021-04-22 Tom Tromey <tom@tromey.com> * gdb.rust/modules.exp: Add checks for syntax errors. * gdb.rust/expr.exp: Add checks for syntax errors. * gdb.rust/simple.exp: Add checks for syntax errors.
Diffstat (limited to 'gdb/testsuite/gdb.rust/expr.exp')
-rw-r--r--gdb/testsuite/gdb.rust/expr.exp2
1 files changed, 2 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.rust/expr.exp b/gdb/testsuite/gdb.rust/expr.exp
index d81b6fc..603e538 100644
--- a/gdb/testsuite/gdb.rust/expr.exp
+++ b/gdb/testsuite/gdb.rust/expr.exp
@@ -111,6 +111,8 @@ gdb_test "print ()" " = \\(\\)"
gdb_test "print \[1,2,3,4\]" " = \\\[1, 2, 3, 4\\\]"
gdb_test "ptype \[1,2,3,4\]" "type = \\\[i32; 4\\\]"
gdb_test "print \[mut 1,2,3,4\]" " = \\\[1, 2, 3, 4\\\]"
+gdb_test "print \[1,2 3" "',' or ']' expected"
+gdb_test "print \[1 2" "',', ';', or ']' expected"
gdb_test "print b\"hi rust\"" " = b\"hi rust\""
# This isn't rusty syntax yet, but that's another bug -- this is just