tresure-chest

This commit is contained in:
Alexander Heldt
2025-11-02 16:11:11 +01:00
parent 64d2de2364
commit 5fb5492306
10 changed files with 261 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
import exercism/should
import exercism/test_runner
import treasure_chest.{TreasureChest, Unlocked, WrongPassword}
pub fn main() {
test_runner.main()
}
pub fn treasure_can_be_a_string_test() {
TreasureChest("password", "treasure")
}
pub fn treasure_can_be_an_int_test() {
TreasureChest("password", 5)
}
pub fn treasure_is_returned_if_correct_password_test() {
TreasureChest("password", "treasure")
|> treasure_chest.get_treasure("password")
|> should.equal(Unlocked("treasure"))
}
pub fn wrong_password_is_returned_if_an_incorrect_password_is_used_test() {
TreasureChest("password", "treasure")
|> treasure_chest.get_treasure("wrong-password")
|> should.equal(WrongPassword)
}