Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 14 additions & 92 deletions compiler/noirc_frontend/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,9 +531,6 @@ fn check_trait_missing_implementation() {
Self { bar: x, array: [x,y] }
}
}

fn main() {
}
";
check_errors!(src);
}
Expand All @@ -552,9 +549,6 @@ fn check_trait_not_in_scope() {
Self { bar: x, array: [x,y] }
}
}

fn main() {
}
";
check_errors!(src);
}
Expand Down Expand Up @@ -600,9 +594,6 @@ fn check_trait_wrong_parameter() {
Foo {bar: x}
}
}

fn main() {
}
";
check_errors!(src);
}
Expand All @@ -625,9 +616,6 @@ fn check_trait_wrong_parameter2() {
Self { bar: x, array: [x, y.bar] }
}
}

fn main() {
}
";
check_errors!(src);
}
Expand Down Expand Up @@ -665,9 +653,6 @@ fn check_trait_wrong_parameters_count() {
Self { bar: x, array: [x, x] }
}
}

fn main() {
}
";
check_errors!(src);
}
Expand Down Expand Up @@ -742,9 +727,6 @@ fn check_trait_duplicate_declaration() {
~~~~~~~~ Second trait definition found here
fn default(x: Field) -> Self;
}

fn main() {
}
";
check_errors!(src);
}
Expand Down Expand Up @@ -815,8 +797,6 @@ fn test_impl_self_within_default_def() {
self
}
}

fn main() { }
";
assert_no_errors!(src);
}
Expand Down Expand Up @@ -1192,8 +1172,6 @@ fn deny_cyclic_globals() {
global B: u32 = A;
^ Variable not in scope
~ Could not find variable

fn main() {}
"#;
check_errors!(src);
}
Expand All @@ -1205,7 +1183,6 @@ fn deny_cyclic_type_aliases() {
type B = A;
^^^^^^^^^^ Dependency cycle found
~~~~~~~~~~ 'B' recursively depends on itself: B -> A -> B
fn main() {}
"#;
check_errors!(src);
}
Expand Down Expand Up @@ -1592,8 +1569,6 @@ fn wrong_type_in_for_range() {
fn numeric_generic_in_function_signature() {
let src = r#"
pub fn foo<let N: u32>(arr: [Field; N]) -> [Field; N] { arr }

fn main() { }
"#;
assert_no_errors!(src);
}
Expand Down Expand Up @@ -1685,8 +1660,6 @@ fn numeric_generic_as_return_type() {
^^^^^^^^ Type annotation needed
~~~~~~~~ Could not determine the type of the generic argument `T` declared on the function `zeroed`
}

fn main() {}
"#;
check_errors!(src);
}
Expand Down Expand Up @@ -1735,8 +1708,6 @@ fn numeric_generic_used_in_nested_type_pass() {
pub struct InnerNumeric<let N: u32> {
inner: [u64; N],
}

fn main() { }
"#;
assert_no_errors!(src);
}
Expand All @@ -1763,8 +1734,6 @@ fn numeric_generic_used_in_trait() {
trait Deserialize<let N: u32, T> {
fn deserialize(fields: [Field; N], other: T) -> Self;
}

fn main() { }
"#;
assert_no_errors!(src);
}
Expand Down Expand Up @@ -1796,8 +1765,6 @@ fn numeric_generic_in_trait_impl_with_extra_impl_generics() {
trait Deserialize<let N: u32> {
fn deserialize(fields: [Field; N]) -> Self;
}

fn main() { }
"#;
assert_no_errors!(src);
}
Expand All @@ -1816,8 +1783,6 @@ fn numeric_generic_used_in_where_clause() {
}
T::deserialize(fields)
}

fn main() { }
"#;
assert_no_errors!(src);
}
Expand All @@ -1835,8 +1800,6 @@ fn numeric_generic_used_in_turbofish() {
assert(double::<9>() == 18);
assert(double::<7 + 8>() == 30);
}

fn main() { }
"#;
assert_no_errors!(src);
}
Expand Down Expand Up @@ -2479,8 +2442,6 @@ fn trait_impl_generics_count_mismatch() {

impl Foo<()> for Field {}
^^^ Foo expects 0 generics but 1 was given

fn main() {}
"#;
check_errors!(src);
}
Expand All @@ -2505,39 +2466,35 @@ fn duplicate_struct_field() {
^ Duplicate definitions of struct field with name x found
~ Second struct field found here
}

fn main() {}
"#;
check_errors!(src);
}

#[test]
fn trait_constraint_on_tuple_type() {
let src = r#"
trait Foo<A> {
fn foo(self, x: A) -> bool;
}

pub fn bar<T, U, V>(x: (T, U), y: V) -> bool where (T, U): Foo<V> {
x.foo(y)
}
trait Foo<A> {
fn foo(self, x: A) -> bool;
}

fn main() {}"#;
pub fn bar<T, U, V>(x: (T, U), y: V) -> bool where (T, U): Foo<V> {
x.foo(y)
}
"#;
assert_no_errors!(src);
}

#[test]
fn trait_constraint_on_tuple_type_pub_crate() {
let src = r#"
pub(crate) trait Foo<A> {
fn foo(self, x: A) -> bool;
}

pub fn bar<T, U, V>(x: (T, U), y: V) -> bool where (T, U): Foo<V> {
x.foo(y)
}
pub(crate) trait Foo<A> {
fn foo(self, x: A) -> bool;
}

fn main() {}"#;
pub fn bar<T, U, V>(x: (T, U), y: V) -> bool where (T, U): Foo<V> {
x.foo(y)
}
"#;
assert_no_errors!(src);
}

Expand Down Expand Up @@ -2700,8 +2657,6 @@ fn trait_impl_for_a_type_that_implements_another_trait() {
pub fn use_it<T>(t: T) -> i32 where T: Two {
Two::two(t)
}

fn main() {}
"#;
assert_no_errors!(src);
}
Expand Down Expand Up @@ -2740,8 +2695,6 @@ fn trait_impl_for_a_type_that_implements_another_trait_with_another_impl_used()
pub fn use_it(t: u32) -> i32 {
Two::two(t)
}

fn main() {}
"#;
assert_no_errors!(src);
}
Expand Down Expand Up @@ -2860,8 +2813,6 @@ fn do_not_infer_partial_global_types() {
^^^^^^^^^^^^^^^^^^^ Globals must have a specified type
(&["hi"], [[]; 3]);
~~~~~~~~~~~~~~~~~~ Inferred type is `([str<2>], [[Field; 0]; 3])`

fn main() { }
"#;
check_errors!(src);
}
Expand Down Expand Up @@ -3202,8 +3153,6 @@ fn uses_self_in_import() {
pub fn baz() -> i32 {
bar::foo()
}

fn main() {}
"#;
assert_no_errors!(src);
}
Expand Down Expand Up @@ -3337,8 +3286,6 @@ fn errors_with_better_message_when_trying_to_invoke_struct_field_that_is_a_funct
~~~~~~~~~~~~~~~ to call the function stored in 'wrapped', surround the field access with parentheses: '(', ')'
}
}

fn main() {}
"#;
check_errors!(src);
}
Expand All @@ -3355,8 +3302,6 @@ fn disallows_test_attribute_on_impl_method() {
fn foo() { }
^^^ The `#[test]` attribute is disallowed on `impl` methods
}

fn main() { }
";
check_errors!(src);
}
Expand All @@ -3375,8 +3320,6 @@ fn disallows_test_attribute_on_trait_impl_method() {
fn foo() { }
^^^ The `#[test]` attribute is disallowed on `impl` methods
}

fn main() { }
";
check_errors!(src);
}
Expand All @@ -3392,8 +3335,6 @@ fn disallows_export_attribute_on_impl_method() {
fn foo() { }
^^^ The `#[export]` attribute is disallowed on `impl` methods
}

fn main() { }
";
check_errors!(src);
}
Expand All @@ -3413,8 +3354,6 @@ fn disallows_export_attribute_on_trait_impl_method() {
fn foo() { }
^^^ The `#[export]` attribute is disallowed on `impl` methods
}

fn main() { }
";
check_errors!(src);
}
Expand All @@ -3423,8 +3362,6 @@ fn disallows_export_attribute_on_trait_impl_method() {
fn allows_multiple_underscore_parameters() {
let src = r#"
pub fn foo(_: i32, _: i64) {}

fn main() {}
"#;
assert_no_errors!(src);
}
Expand Down Expand Up @@ -3452,8 +3389,6 @@ fn errors_on_cyclic_globals() {
pub comptime global B: u32 = A;
^ Variable not in scope
~ Could not find variable

fn main() { }
"#;
check_errors!(src);
}
Expand Down Expand Up @@ -3633,9 +3568,6 @@ fn infers_lambda_argument_from_function_return_type() {
pub fn func() -> fn(Foo) -> Field {
|foo| foo.value
}

fn main() {
}
"#;
assert_no_errors!(src);
}
Expand All @@ -3651,9 +3583,6 @@ fn infers_lambda_argument_from_function_return_type_multiple_statements() {
let _ = 1;
|foo| foo.value
}

fn main() {
}
"#;
assert_no_errors!(src);
}
Expand All @@ -3672,9 +3601,6 @@ fn infers_lambda_argument_from_function_return_type_when_inside_if() {
|foo| foo.value
}
}

fn main() {
}
"#;
assert_no_errors!(src);
}
Expand Down Expand Up @@ -3940,8 +3866,6 @@ fn check_impl_duplicate_method_without_self() {
^^^ duplicate definitions of foo found
~~~ second definition found here
}

fn main() {}
";
check_errors!(src);
}
Expand Down Expand Up @@ -4204,8 +4128,6 @@ fn object_type_must_be_known_in_method_call() {
~~~ Type must be known by this point to know which method to call
bar
}

fn main() {}
"#;
check_errors!(src);
}
Expand Down
2 changes: 0 additions & 2 deletions compiler/noirc_frontend/src/tests/aliases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ fn double_generic_alias_in_path() {
fn identity_numeric_type_alias_works() {
let src = r#"
pub type Identity<let N: u32>: u32 = N;

fn main() {}
"#;
assert_no_errors!(src);
}
Expand Down
3 changes: 0 additions & 3 deletions compiler/noirc_frontend/src/tests/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ fn error_with_duplicate_enum_variant() {
^^^ Duplicate definitions of enum variant with name Bar found
~~~ Second enum variant found here
}

fn main() {}
"#;
check_errors!(src);
}
Expand Down Expand Up @@ -364,7 +362,6 @@ fn match_on_empty_enum() {
match v {}
}
pub enum Void {}
fn main() {}
",
&features
);
Expand Down
Loading
Loading