Skip to content

Commit

Permalink
Enhance let tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dusty-phillips committed Sep 12, 2024
1 parent 936b61a commit a98081c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/typecheck/assignment_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ pub fn assign_let_with_type() {
|> should.equal(option.Some(glance.NamedType("Int", option.None, [])))
}

pub fn assign_let_with_binop() {
let function_out =
helpers.ok_function_typecheck(
"fn foo() -> Int {
let x = 5
let y: Int = 5 + a
y + 2}",
)

function_out.return
|> should.equal(option.Some(glance.NamedType("Int", option.None, [])))
}

pub fn assign_let_incorrect_type_test() {
helpers.error_function_typecheck(
"fn foo() {
Expand All @@ -44,3 +57,12 @@ pub fn assign_let_incorrect_type_test() {
)
|> should.equal(error.InvalidType("Int", "String", "during assignment of x"))
}

pub fn assign_let_value_error_test() {
helpers.error_function_typecheck(
"fn foo() {
let x: String = a
}",
)
|> should.equal(error.InvalidName("a"))
}

0 comments on commit a98081c

Please sign in to comment.