Skip to content

Commit

Permalink
chore(tests): order tests alphabetically
Browse files Browse the repository at this point in the history
  • Loading branch information
0xLucqs committed Aug 8, 2024
1 parent 27fc530 commit 6b28521
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 100 deletions.
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ test-case = "3.0"
pretty_assertions = "1.4.0"
ctor = "0.2.8"
paste = "1.0.15"
itertools = "0.13.0"
1 change: 1 addition & 0 deletions crates/cairo-lint-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ pretty_assertions.workspace = true
ctor.workspace = true
cairo-lint-test-utils = { path = "../cairo-lint-test-utils" }
paste.workspace = true
itertools.workspace = true
180 changes: 90 additions & 90 deletions crates/cairo-lint-core/tests/test_files/destruct_if_let
Original file line number Diff line number Diff line change
@@ -1,96 +1,90 @@
//! > simple destructuring match with scope
//! > nested destructuring match

//! > cairo_code
fn main() {
let variable = Option::Some(1_felt252);
let variable = Option::Some(Option::Some(1_felt252));
match variable {
Option::Some(a) => println!("{a}"),
_ => {},
Option::Some(a) => match a {
Option::Some(b) => println!("{b}"),
_ => (),
},
_ => (),
};
}

//! > diagnostics
warning: Plugin diagnostic: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
--> lib.cairo:3:2
\ match variable {
| Option::Some(a) => println!("{a}"),
| _ => {},
| Option::Some(a) => match a {
| Option::Some(b) => println!("{b}"),
| _ => (),
| },
| _ => (),
| }
|___^

//! > fixed
fn main() {
let variable = Option::Some(1_felt252);
if let Option::Some(a) = variable { println!("{a}") };
}

//! > ==========================================================================

//! > simple destructuring match with scope second arm

//! > cairo_code
fn main() {
let variable = Option::Some(1_felt252);
match variable {
_ => {},
Option::Some(a) => println!("{a}"),
};
}

//! > diagnostics
warning: Plugin diagnostic: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
--> lib.cairo:3:2
\ match variable {
| _ => {},
| Option::Some(a) => println!("{a}"),
--> lib.cairo:4:22
\ Option::Some(a) => match a {
| Option::Some(b) => println!("{b}"),
| _ => (),
| }
|___^

//! > fixed
fn main() {
let variable = Option::Some(1_felt252);
if let Option::Some(a) = variable { println!("{a}") };
}
Contains nested diagnostics can't fix it

//! > ==========================================================================

//! > simple destructuring match with unit in scope
//! > nested destructuring match second arm

//! > cairo_code
fn main() {
let variable = Option::Some(1_felt252);
let variable = Option::Some(Option::Some(1_felt252));
match variable {
Option::Some(a) => println!("{a}"),
_ => { () },
_ => (),
Option::Some(a) => match a {
_ => (),
Option::Some(b) => println!("{b}"),
},
};
}

//! > diagnostics
warning: Plugin diagnostic: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
--> lib.cairo:3:2
\ match variable {
| Option::Some(a) => println!("{a}"),
| _ => { () },
| _ => (),
| Option::Some(a) => match a {
| _ => (),
| Option::Some(b) => println!("{b}"),
| },
| }
|___^

warning: Plugin diagnostic: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
--> lib.cairo:5:22
\ Option::Some(a) => match a {
| _ => (),
| Option::Some(b) => println!("{b}"),
| }
|___^

//! > fixed
fn main() {
let variable = Option::Some(1_felt252);
if let Option::Some(a) = variable { println!("{a}") };
}
Contains nested diagnostics can't fix it

//! > ==========================================================================

//! > nested destructuring match
//! > nested destructuring match twisted

//! > cairo_code
fn main() {
let variable = Option::Some(Option::Some(1_felt252));
match variable {
Option::Some(a) => match a {
Option::Some(b) => println!("{b}"),
_ => (),
Option::Some(b) => println!("{b}"),
},
_ => (),
};
Expand All @@ -101,8 +95,8 @@ warning: Plugin diagnostic: you seem to be trying to use `match` for destructuri
--> lib.cairo:3:2
\ match variable {
| Option::Some(a) => match a {
| Option::Some(b) => println!("{b}"),
| _ => (),
| Option::Some(b) => println!("{b}"),
| },
| _ => (),
| }
Expand All @@ -111,8 +105,8 @@ warning: Plugin diagnostic: you seem to be trying to use `match` for destructuri
warning: Plugin diagnostic: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
--> lib.cairo:4:22
\ Option::Some(a) => match a {
| Option::Some(b) => println!("{b}"),
| _ => (),
| Option::Some(b) => println!("{b}"),
| }
|___^

Expand Down Expand Up @@ -160,16 +154,13 @@ Contains nested diagnostics can't fix it

//! > ==========================================================================

//! > nested destructuring match twisted
//! > simple destructuring match

//! > cairo_code
fn main() {
let variable = Option::Some(Option::Some(1_felt252));
let variable = Option::Some(1_felt252);
match variable {
Option::Some(a) => match a {
_ => (),
Option::Some(b) => println!("{b}"),
},
Option::Some(a) => println!("{a}"),
_ => (),
};
}
Expand All @@ -178,24 +169,16 @@ fn main() {
warning: Plugin diagnostic: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
--> lib.cairo:3:2
\ match variable {
| Option::Some(a) => match a {
| _ => (),
| Option::Some(b) => println!("{b}"),
| },
| _ => (),
| }
|___^

warning: Plugin diagnostic: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
--> lib.cairo:4:22
\ Option::Some(a) => match a {
| Option::Some(a) => println!("{a}"),
| _ => (),
| Option::Some(b) => println!("{b}"),
| }
|___^

//! > fixed
Contains nested diagnostics can't fix it
fn main() {
let variable = Option::Some(1_felt252);
if let Option::Some(a) = variable { println!("{a}") };
}

//! > ==========================================================================

Expand Down Expand Up @@ -227,23 +210,23 @@ fn main() {

//! > ==========================================================================

//! > simple destructuring match with unit in scope second arm
//! > simple destructuring match with scope

//! > cairo_code
fn main() {
let variable = Option::Some(1_felt252);
match variable {
_ => { () },
Option::Some(a) => println!("{a}"),
_ => {},
};
}

//! > diagnostics
warning: Plugin diagnostic: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
--> lib.cairo:3:2
\ match variable {
| _ => { () },
| Option::Some(a) => println!("{a}"),
| _ => {},
| }
|___^

Expand All @@ -255,23 +238,23 @@ fn main() {

//! > ==========================================================================

//! > simple destructuring match
//! > simple destructuring match with scope second arm

//! > cairo_code
fn main() {
let variable = Option::Some(1_felt252);
match variable {
_ => {},
Option::Some(a) => println!("{a}"),
_ => (),
};
}

//! > diagnostics
warning: Plugin diagnostic: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
--> lib.cairo:3:2
\ match variable {
| _ => {},
| Option::Some(a) => println!("{a}"),
| _ => (),
| }
|___^

Expand All @@ -283,39 +266,56 @@ fn main() {

//! > ==========================================================================

//! > nested destructuring match second arm
//! > simple destructuring match with unit in scope

//! > cairo_code
fn main() {
let variable = Option::Some(Option::Some(1_felt252));
let variable = Option::Some(1_felt252);
match variable {
_ => (),
Option::Some(a) => match a {
_ => (),
Option::Some(b) => println!("{b}"),
},
Option::Some(a) => println!("{a}"),
_ => { () },
};
}

//! > diagnostics
warning: Plugin diagnostic: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
--> lib.cairo:3:2
\ match variable {
| _ => (),
| Option::Some(a) => match a {
| _ => (),
| Option::Some(b) => println!("{b}"),
| },
| Option::Some(a) => println!("{a}"),
| _ => { () },
| }
|___^

//! > fixed
fn main() {
let variable = Option::Some(1_felt252);
if let Option::Some(a) = variable { println!("{a}") };
}

//! > ==========================================================================

//! > simple destructuring match with unit in scope second arm

//! > cairo_code
fn main() {
let variable = Option::Some(1_felt252);
match variable {
_ => { () },
Option::Some(a) => println!("{a}"),
};
}

//! > diagnostics
warning: Plugin diagnostic: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
--> lib.cairo:5:22
\ Option::Some(a) => match a {
| _ => (),
| Option::Some(b) => println!("{b}"),
--> lib.cairo:3:2
\ match variable {
| _ => { () },
| Option::Some(a) => println!("{a}"),
| }
|___^

//! > fixed
Contains nested diagnostics can't fix it
fn main() {
let variable = Option::Some(1_felt252);
if let Option::Some(a) = variable { println!("{a}") };
}
Loading

0 comments on commit 6b28521

Please sign in to comment.