From 72a65125cc6926fe9019ea74d967b9b1e47ce0a3 Mon Sep 17 00:00:00 2001 From: xunilrj Date: Tue, 10 Sep 2024 14:27:23 +0100 Subject: [PATCH] more tests --- .../array_wrong_elements_types/src/main.sw | 6 +- .../array_wrong_elements_types/stdout.snap | 73 +++++++++++-------- 2 files changed, 49 insertions(+), 30 deletions(-) diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/array_wrong_elements_types/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_fail/array_wrong_elements_types/src/main.sw index 5d2e92872e3..ca7e2611018 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/array_wrong_elements_types/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_fail/array_wrong_elements_types/src/main.sw @@ -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 let _ = [Vec::new(), vec::(), vec::()]; @@ -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] = []; } diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/array_wrong_elements_types/stdout.snap b/test/src/e2e_vm_tests/test_programs/should_fail/array_wrong_elements_types/stdout.snap index 3566184a6b0..3df03eb69cf 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/array_wrong_elements_types/stdout.snap +++ b/test/src/e2e_vm_tests/test_programs/should_fail/array_wrong_elements_types/stdout.snap @@ -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 = a[1]; +39 | +40 | let a = [None, Some(1), Some(1u8)]; +41 | let _b: Option = a[1]; | ^^^^ Mismatched types. expected: Option found: Option. 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 | ____ @@ -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]; | ____ @@ -222,12 +223,13 @@ 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]; | ____ @@ -235,46 +237,59 @@ 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 +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 -36 | let _ = [Vec::new(), vec::(), vec::()]; +32 | +33 | let _ = [1, return, "", 1u16]; +34 | let _ = [1, "", return, 1u16]; + | ^^ Mismatched types. +expected: u16 +found: str. + +35 | +36 | // unexpected Vec + | +____ + +error + --> test/src/e2e_vm_tests/test_programs/should_fail/array_wrong_elements_types/src/main.sw:37:39 + | +35 | +36 | // unexpected Vec +37 | let _ = [Vec::new(), vec::(), vec::()]; | ^^^^^^^^^^^^ Mismatched types. expected: Vec found: Vec. -37 | -38 | // unexpected Option +38 | +39 | // unexpected Option | ____ 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