Skip to content

Commit

Permalink
fix: char
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-jerry-ye committed Apr 3, 2024
1 parent f00c739 commit e6306a4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 43 deletions.
4 changes: 0 additions & 4 deletions examples/char/lib/char.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,3 @@ pub fn prev(c : Char) -> Option[Char] {
None
}

fn Char::from_int(self : Int) -> Char {
obj_magic(self)
}

4 changes: 1 addition & 3 deletions examples/char/lib/moon.pkg.json
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
{
"name": "lib"
}
{}
46 changes: 11 additions & 35 deletions examples/char/main/main.mbt
Original file line number Diff line number Diff line change
@@ -1,37 +1,13 @@
fn init {
match @lib.is_alpha('a') {
true => println("is alpha")
false => println("is not alpha")
}
match @lib.is_alpha('3') {
true => println("is alpha")
false => println("is not alpha")
}
match @lib.is_numeric('1') {
true => println("is numeric")
false => println("is not numeric")
}
match @lib.is_numeric('b') {
true => println("is numeric")
false => println("is not numeric")
}
match @lib.is_alphanumeric('a') {
true => println("is alphanumeric")
false => println("is not alphanumeric")
}
println(@lib.to_lower('H'))
println(@lib.to_upper('c'))
match @lib.is_whitespace(' ') {
true => println("True")
false => println("False")
}
match @lib.next('Z') {
Some(v) => println(v)
None => ()
}
match @lib.prev('A') {
Some(v) => println(v)
None => ()
}
test {
@assertion.assert_true(@lib.is_alpha('a'))?
@assertion.assert_false(@lib.is_alpha('3'))?
@assertion.assert_true(@lib.is_numeric('1'))?
@assertion.assert_false(@lib.is_numeric('b'))?
@assertion.assert_true(@lib.is_alphanumeric('a'))?
@assertion.assert_eq(@lib.to_lower('H'), 'h')?
@assertion.assert_eq(@lib.to_upper('c'), 'C')?
@assertion.assert_true(@lib.is_whitespace(' '))?
@assertion.assert_eq(@lib.next('Z'), Some('['))?
@assertion.assert_eq(@lib.prev('A'), Some('@'))?
}

1 change: 0 additions & 1 deletion examples/char/main/moon.pkg.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"name": "main",
"import": {
"char/lib": ""
}
Expand Down

0 comments on commit e6306a4

Please sign in to comment.