tests: audit buffer and error-value rejection twins
This commit is contained in:
1 parent
2742867ef7
commit
5371eb7a2f
14 files changed
+273
-17
No files matched your search
@@ -2,5 +2,5 @@
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §5/§10; docs/spec/07-air.md §8.8
|
||||
module test.array_literals
|
||||
fn unused(p: ref<u64>) -> void effects [] { let a = [p, p]; }
|
||||
fn unused(p: ref<u64>) -> void effects [] { let a = [p, p]; } // diagnostic here: p, p]
|
||||
fn main() -> void effects [] {}
|
||||
@@ -5,7 +5,7 @@
|
||||
// spec: docs/spec/03-memory-model.md §26; docs/spec/15-source-language.md §17
|
||||
module test.buffers
|
||||
fn bad(heap: cap<mem.alloc>, value: ref<u64>) -> void effects [mem.alloc] {
|
||||
let data = buffer.new<ref<u64>>(1, heap) or trap;
|
||||
let data = buffer.new<ref<u64>>(1, heap) or trap; // diagnostic here: ref<u64>>(1
|
||||
buffer.free(move data) or trap;
|
||||
}
|
||||
fn main() -> u64 effects [] { return 42; }
|
||||
@@ -2,4 +2,4 @@
|
||||
// phase: 6
|
||||
// spec: docs/spec/05-effects-and-capabilities.md §14
|
||||
module test.errors
|
||||
fn main() -> cap<mem.alloc> effects [] { return alloc_error::budget_exceeded; }
|
||||
fn main() -> cap<mem.alloc> effects [] { return alloc_error::budget_exceeded; } // diagnostic here: alloc_error::budget_exceeded;
|
||||
@@ -2,4 +2,4 @@
|
||||
// phase: 6
|
||||
// spec: docs/spec/05-effects-and-capabilities.md §14
|
||||
module test.errors
|
||||
fn main() -> alloc_error effects [] { return alloc_error::budget_exceeded(1u64); }
|
||||
fn main() -> alloc_error effects [] { return alloc_error::budget_exceeded(1u64); } // diagnostic here: alloc_error::budget_exceeded(1u64)
|
||||
@@ -2,4 +2,4 @@
|
||||
// phase: 6
|
||||
// spec: docs/spec/05-effects-and-capabilities.md §14
|
||||
module test.errors
|
||||
fn main() -> alloc_error effects [] { return alloc_error::invalid; }
|
||||
fn main() -> alloc_error effects [] { return alloc_error::invalid; } // diagnostic here: alloc_error::invalid
|
||||
@@ -2,4 +2,4 @@
|
||||
// phase: 6
|
||||
// spec: docs/spec/05-effects-and-capabilities.md §14
|
||||
module test.errors
|
||||
fn main() -> io_error effects [] { return alloc_error::budget_exceeded; }
|
||||
fn main() -> io_error effects [] { return alloc_error::budget_exceeded; } // diagnostic here: alloc_error::budget_exceeded;
|
||||
@@ -0,0 +1,11 @@
|
||||
// expect: reject E2101
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §17
|
||||
// AIR twin: buffers/readonly_view_push.air
|
||||
module test.readonly_view_push
|
||||
fn bad(b: mut<buffer<u64>>) -> void effects [] {
|
||||
ref view = buffer.view(b);
|
||||
buffer.push(b, 42u64) or trap; // diagnostic here
|
||||
trap;
|
||||
}
|
||||
fn main() -> u64 effects [] { return 42; }
|
||||
@@ -0,0 +1,10 @@
|
||||
// expect: reject E3101
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §17
|
||||
// AIR twin: buffers/reserve_missing_effect.air
|
||||
module test.reserve_missing_effect
|
||||
fn bad(b: mut<buffer<u64>>, heap: cap<mem.alloc>) -> void effects [] {
|
||||
buffer.reserve(b, 2usize, heap) or trap; // diagnostic here
|
||||
trap;
|
||||
}
|
||||
fn main() -> u64 effects [] { return 42; }
|
||||
@@ -0,0 +1,10 @@
|
||||
// expect: reject E3201
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md §17
|
||||
// AIR twin: buffers/wrong_capability.air
|
||||
module test.buffer_wrong_capability
|
||||
fn bad(b: mut<buffer<u64>>, cap: cap<io.write>) -> void effects [mem.alloc] {
|
||||
buffer.reserve(b, 0usize, cap) or trap; // diagnostic here
|
||||
trap;
|
||||
}
|
||||
fn main() -> u64 effects [] { return 42; }
|
||||
Reference in new issue
Block a user