test/684: add 1-element [_] edge + module element read-back rows
The reviewer flagged two gaps in the #7 coverage: no minimal non-empty count (a 1-element [_] is the boundary the element-counter must still get right) and no module-level array element read-back (only .len was checked at module scope). Add local_one_len / mod_one_len / mod_one_elem. Both still mutation-resistant: the old collapse-to-0 reads .len as 0, not 1, so the new len rows fail it too. 42/42 dual-stage + byte-id.
This commit is contained in:
@@ -41,6 +41,9 @@
|
||||
* mod_str_len | global [_]str=["a","b","c"], x.len | 3
|
||||
* local_u8_len | local [_]u8=[1..5], x.len | 5
|
||||
* local_u8_elem | local, x[4] | 5
|
||||
* local_one_len | local [_]int=[7], x.len (1-elem edge)| 1
|
||||
* mod_one_len | global [_]int=[7], x.len | 1
|
||||
* mod_one_elem | global, x[0] | 7
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -132,6 +135,33 @@ static const struct row rows[] = {
|
||||
"\treturn x[4]: i32;\n"
|
||||
"};\n",
|
||||
5 },
|
||||
|
||||
/* 1-element edge — the minimal non-empty count; under the old
|
||||
* collapse-to-0 bug `.len` reads 0, not 1, so this row also fails
|
||||
* the mutation. */
|
||||
{ "local_one_len",
|
||||
"package main;\n"
|
||||
"export fn main() i32 = {\n"
|
||||
"\tlet x: [_]int = [7];\n"
|
||||
"\treturn x.len: i32;\n"
|
||||
"};\n",
|
||||
1 },
|
||||
|
||||
{ "mod_one_len",
|
||||
"package main;\n"
|
||||
"let x: [_]int = [7];\n"
|
||||
"export fn main() i32 = {\n"
|
||||
"\treturn x.len: i32;\n"
|
||||
"};\n",
|
||||
1 },
|
||||
|
||||
{ "mod_one_elem",
|
||||
"package main;\n"
|
||||
"let x: [_]int = [7];\n"
|
||||
"export fn main() i32 = {\n"
|
||||
"\treturn x[0]: i32;\n"
|
||||
"};\n",
|
||||
7 },
|
||||
};
|
||||
|
||||
/* `[_]T` that can't infer its length — both stages must FAIL the build
|
||||
|
||||
Reference in New Issue
Block a user