Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xunilrj committed Sep 10, 2024
1 parent bbbada3 commit 72a6512
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ fn main() {

// unexpected str
let _ = [1, "", 1u16];
let a = [1, 2, "hello"];
let _ = [1, 2, "hello"];
let _ = [1, return, "", 1u16];
let _ = [1, "", return, 1u16];

// unexpected Vec<u16>
let _ = [Vec::new(), vec::<u8>(), vec::<u16>()];
Expand All @@ -42,4 +43,7 @@ fn main() {
// unexpected u8
let a = [8, 256u16, 8u8];
let b: u32 = a[2];

// Should not warn or error
let _ : [u8 ; 0] = [];
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,32 @@ stdout:

stderr:
error
--> test/src/e2e_vm_tests/test_programs/should_fail/array_wrong_elements_types/src/main.sw:40:27
--> test/src/e2e_vm_tests/test_programs/should_fail/array_wrong_elements_types/src/main.sw:41:27
|
38 |
39 | let a = [None, Some(1), Some(1u8)];
40 | let _b: Option<u16> = a[1];
39 |
40 | let a = [None, Some(1), Some(1u8)];
41 | let _b: Option<u16> = a[1];
| ^^^^ Mismatched types.
expected: Option<u16>
found: Option<u8>.
help: Variable declaration's type annotation does not match up with the assigned expression's type.
41 |
42 | // unexpected u8
42 |
43 | // unexpected u8
|
____

error
--> test/src/e2e_vm_tests/test_programs/should_fail/array_wrong_elements_types/src/main.sw:44:18
--> test/src/e2e_vm_tests/test_programs/should_fail/array_wrong_elements_types/src/main.sw:45:18
|
42 |
43 | let a = [8, 256u16, 8u8];
44 | let b: u32 = a[2];
43 |
44 | let a = [8, 256u16, 8u8];
45 | let b: u32 = a[2];
| ^^^^ Mismatched types.
expected: u32
found: u16.
help: Variable declaration's type annotation does not match up with the assigned expression's type.
45 | }
46 |
47 | // Should not warn or error
|
____

Expand Down Expand Up @@ -212,7 +213,7 @@ error
expected: u16
found: str.

32 | let a = [1, 2, "hello"];
32 | let _ = [1, 2, "hello"];
33 | let _ = [1, return, "", 1u16];
|
____
Expand All @@ -222,59 +223,73 @@ error
|
30 |
31 | let _ = [1, "", 1u16];
32 | let a = [1, 2, "hello"];
32 | let _ = [1, 2, "hello"];
| ^^^^^^^ Mismatched types.
expected: numeric
found: str.

33 | let _ = [1, return, "", 1u16];
34 | let _ = [1, "", return, 1u16];
|
____

error
--> test/src/e2e_vm_tests/test_programs/should_fail/array_wrong_elements_types/src/main.sw:33:25
|
31 |
32 | let a = [1, 2, "hello"];
32 | let _ = [1, 2, "hello"];
33 | let _ = [1, return, "", 1u16];
| ^^ Mismatched types.
expected: u16
found: str.

34 |
35 | // unexpected Vec<u16>
34 | let _ = [1, "", return, 1u16];
|
____

error
--> test/src/e2e_vm_tests/test_programs/should_fail/array_wrong_elements_types/src/main.sw:36:39
--> test/src/e2e_vm_tests/test_programs/should_fail/array_wrong_elements_types/src/main.sw:34:17
|
34 |
35 | // unexpected Vec<u16>
36 | let _ = [Vec::new(), vec::<u8>(), vec::<u16>()];
32 |
33 | let _ = [1, return, "", 1u16];
34 | let _ = [1, "", return, 1u16];
| ^^ Mismatched types.
expected: u16
found: str.

35 |
36 | // unexpected Vec<u16>
|
____

error
--> test/src/e2e_vm_tests/test_programs/should_fail/array_wrong_elements_types/src/main.sw:37:39
|
35 |
36 | // unexpected Vec<u16>
37 | let _ = [Vec::new(), vec::<u8>(), vec::<u16>()];
| ^^^^^^^^^^^^ Mismatched types.
expected: Vec<u8>
found: Vec<u16>.

37 |
38 | // unexpected Option<u8>
38 |
39 | // unexpected Option<u8>
|
____

error
--> test/src/e2e_vm_tests/test_programs/should_fail/array_wrong_elements_types/src/main.sw:43:25
--> test/src/e2e_vm_tests/test_programs/should_fail/array_wrong_elements_types/src/main.sw:44:25
|
41 |
42 | // unexpected u8
43 | let a = [8, 256u16, 8u8];
42 |
43 | // unexpected u8
44 | let a = [8, 256u16, 8u8];
| ^^^ Mismatched types.
expected: u16
found: u8.

44 | let b: u32 = a[2];
45 | }
45 | let b: u32 = a[2];
|
____

Aborting due to 18 errors.
Aborting due to 19 errors.
error: Failed to compile array_wrong_elements_types

0 comments on commit 72a6512

Please sign in to comment.