compiler/
lib/
examples/
std/
arch/
char/
collections/
graph/
lang/
alloc/
ast/
gen/
il/
module/
parser/
resolver/
tests/
placeholderTests.rad
1.5 KiB
regions.rad
148.1 KiB
opaqueTests.rad
6.6 KiB
printer.rad
25.5 KiB
tests.rad
410.1 KiB
scanner/
alloc.rad
7.1 KiB
ast.rad
26.9 KiB
gen.rad
513 B
il.rad
20.4 KiB
lower.rad
321.7 KiB
module.rad
17.3 KiB
package.rad
1.3 KiB
parser.rad
92.2 KiB
resolver.rad
511.1 KiB
scanner.rad
17.9 KiB
sexpr.rad
6.7 KiB
strings.rad
2.2 KiB
types.rad
1.6 KiB
sys/
arch.rad
68 B
char.rad
855 B
collections.rad
39 B
fmt.rad
8.3 KiB
graph.rad
4.3 KiB
intrinsics.rad
467 B
io.rad
1.7 KiB
lang.rad
276 B
mem.rad
2.3 KiB
sys.rad
179 B
testing.rad
2.4 KiB
tests.rad
15.7 KiB
vec.rad
3.2 KiB
std.rad
299 B
scripts/
seed/
sublime/
test/
vim/
.gitignore
336 B
.gitsigners
112 B
CELL_PERMISSIONS
6.8 KiB
CONTRIBUTING
2.1 KiB
LICENSE
1.1 KiB
Makefile
5.4 KiB
README
2.5 KiB
STYLE
2.5 KiB
std.lib
1.5 KiB
std.lib.test
808 B
lib/std/lang/resolver/tests/placeholderTests.rad
raw
| 1 | //! Placeholder resolver tests. |
| 2 | |
| 3 | use std::testing; |
| 4 | use std::lang::resolver; |
| 5 | |
| 6 | /// Test array pattern with placeholder elements. |
| 7 | /// Pattern syntax: `[_, y]` ignores first element. |
| 8 | @test unsafe fn testResolveMatchArrayPatternPlaceholder() throws (testing::TestError) { |
| 9 | let mut testArena389 = super::testArena(); |
| 10 | let testStorage389: 'test389 = &mut testArena389 in { |
| 11 | let mut a = super::testResolver(testStorage389); |
| 12 | let program = "fn f(arr: [i32; 2]) -> i32 { match arr { case [_, y] => return y } }"; |
| 13 | let result = try super::resolveProgramStr(&mut a, program); |
| 14 | try super::expectNoErrors(&result); |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | /// Placeholders cannot supply values to expressions. |
| 19 | @test unsafe fn testPlaceholderValueRejected() throws (testing::TestError) { |
| 20 | for program in [ |
| 21 | "fn value() -> u32 { return _; }", |
| 22 | "fn take(value: u32) {} fn run() { take(_); }", |
| 23 | "record R: Copy { value: u32 } fn run() { let value = R { value: _ }; }", |
| 24 | "fn run() { let value: [u32; 1] = [_]; }", |
| 25 | "union U: Copy { Value(u32) } fn run() { let value = U::Value(_); }", |
| 26 | "union U: Copy { Value(u32) } fn run(value: &?U) { match value { case U::Value(_) => {} else => {} } }", |
| 27 | ] { |
| 28 | let mut arena = super::testArena(); |
| 29 | let storage: 'placeholder = &mut arena in { |
| 30 | let mut res = super::testResolver(storage); |
| 31 | let result = try super::resolveProgramStr(&mut res, program); |
| 32 | try super::expectErrorKind(&result, resolver::ErrorKind::PlaceholderExpression); |
| 33 | } |
| 34 | } |
| 35 | } |