Skip to content

Commit

Permalink
hacking
Browse files Browse the repository at this point in the history
  • Loading branch information
g-r-a-n-t committed Jun 29, 2022
1 parent 5e7ca62 commit a66598c
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/analyzer/tests/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,3 +341,4 @@ test_file! { ctx_builtins_param_incorrect_type }
test_file! { ctx_undefined_create }
test_file! { ctx_undefined_create2 }
test_file! { ctx_undefined_event }
test_file! { uninit_values }
18 changes: 18 additions & 0 deletions crates/analyzer/tests/snapshots/errors__uninit_values.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
source: crates/analyzer/tests/errors.rs
expression: "error_string(&path, test_files::fixture(path))"

---
error: uninitialized variable
┌─ compile_errors/uninit_values.fe:7:13
7let my_struct: MyStruct
^^^^^^^^^ uninitialized variable

error: uninitialized variable
┌─ compile_errors/uninit_values.fe:8:13
8let my_array: Array<u256, 42>
^^^^^^^^ uninitialized variable


10 changes: 10 additions & 0 deletions crates/test-files/fixtures/compile_errors/uninit_values.fe
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
struct MyStruct {
x: u256
}

contract Foo {
pub fn foo() {
let my_struct: MyStruct
let my_array: Array<u256, 42>
}
}
7 changes: 7 additions & 0 deletions crates/test-files/fixtures/features/array_repeat.fe
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
contract Foo {
pub fn foo() -> Array<u256, 4> {
let my_array: Array<u256, 4> = [8; 4]
my_array[1] = 42
return my_array
}
}
8 changes: 8 additions & 0 deletions crates/tests/src/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2072,3 +2072,11 @@ fn generics() {
harness.test_function(&mut executor, "generic_compute", &[], None);
});
}

#[test]
fn array_repeat() {
with_executor(&|mut executor| {
let harness = deploy_contract(&mut executor, "array_repeat.fe", "Foo", &[]);
harness.test_function(&mut executor, "foo", &[], Some(&uint_array_token(&[8, 42, 8, 8])));
});
}

0 comments on commit a66598c

Please sign in to comment.