-
-
Notifications
You must be signed in to change notification settings - Fork 753
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b83e497
commit 6567af2
Showing
9 changed files
with
200 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
use crate::{assert_module_error, assert_module_infer}; | ||
|
||
#[test] | ||
pub fn echo_has_same_type_as_printed_expression() { | ||
assert_module_infer!( | ||
r#" | ||
pub fn main() { | ||
echo 1 | ||
} | ||
"#, | ||
vec![("main", "fn() -> Int")] | ||
); | ||
} | ||
|
||
#[test] | ||
pub fn echo_has_same_type_as_printed_expression_2() { | ||
assert_module_infer!( | ||
r#" | ||
pub fn main() { | ||
let wibble = todo | ||
echo wibble | ||
} | ||
"#, | ||
vec![("main", "fn() -> a")] | ||
); | ||
} | ||
|
||
#[test] | ||
pub fn echo_in_pipeline_acts_as_the_identity_function() { | ||
assert_module_infer!( | ||
r#" | ||
pub fn main() { | ||
[1, 2, 3] | ||
|> echo | ||
} | ||
"#, | ||
vec![("main", "fn() -> List(Int)")] | ||
); | ||
} | ||
|
||
#[test] | ||
pub fn echo_in_pipeline_acts_as_the_identity_function_2() { | ||
assert_module_infer!( | ||
r#" | ||
pub fn main() { | ||
1 | ||
|> echo | ||
|> fn(_: Int) { True } | ||
} | ||
"#, | ||
vec![("main", "fn() -> Bool")] | ||
); | ||
} | ||
|
||
#[test] | ||
pub fn echo_in_pipeline_acts_as_the_identity_function_3() { | ||
assert_module_infer!( | ||
r#" | ||
pub fn main() { | ||
[1, 2, 3] | ||
|> echo | ||
|> echo | ||
|> wibble | ||
} | ||
fn wibble(_: List(Int)) -> List(String) { todo } | ||
"#, | ||
vec![("main", "fn() -> List(String)")] | ||
); | ||
} | ||
|
||
#[test] | ||
pub fn echo_in_pipeline_printing_a_function() { | ||
assert_module_infer!( | ||
r#" | ||
pub fn main() { | ||
[1, 2, 3] | ||
|> echo wibble | ||
} | ||
fn wibble(_: List(Int)) -> List(String) { todo } | ||
"#, | ||
vec![("main", "fn() -> List(String)")] | ||
); | ||
} | ||
|
||
#[test] | ||
pub fn echo_in_pipeline_printing_a_function_2() { | ||
assert_module_error!( | ||
r#" | ||
pub fn main() { | ||
[1, 2, 3] | ||
|> echo wibble | ||
} | ||
fn wibble(_: List(Float)) -> List(String) { todo } | ||
"# | ||
); | ||
} |
17 changes: 17 additions & 0 deletions
17
...sts/snapshots/gleam_core__type___tests__echo__echo_in_pipeline_printing_a_function_2.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
source: compiler-core/src/type_/tests/echo.rs | ||
expression: "\npub fn main() {\n [1, 2, 3]\n |> echo wibble\n}\n\nfn wibble(_: List(Float)) -> List(String) { todo }\n" | ||
--- | ||
error: Type mismatch | ||
┌─ /src/one/two.gleam:4:6 | ||
│ | ||
4 │ |> echo wibble | ||
│ ^^^^^^^^^^^ This function does not accept the piped type | ||
|
||
The argument is: | ||
|
||
List(Int) | ||
|
||
But function expects: | ||
|
||
List(Float) |