Skip to content

Commit

Permalink
use assert_eq and \{..} (#49)
Browse files Browse the repository at this point in the history
Co-authored-by: Haoxiang Fei <feihaoxiang@idea.edu.cn>
  • Loading branch information
tonyfettes and tonyfettes authored Sep 3, 2024
1 parent 21b780e commit 7048bc1
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions docs/01-program-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ The process of writing test cases not only helps in validating the solution but

```moonbit
test {
@test.eq!(num_water_bottles(9, 3), 13) // 9 + 3 + 1 = 13
@test.eq!(num_water_bottles(15, 4), 19)
assert_eq!(num_water_bottles(9, 3), 13) // 9 + 3 + 1 = 13
assert_eq!(num_water_bottles(15, 4), 19)
}
```

Expand All @@ -91,8 +91,8 @@ fn num_water_bottles(num_bottles: Int, num_exchange: Int) -> Int {
}
test {
@test.eq!(num_water_bottles(9, 3), 13) // 9 + 3 + 1 = 13
@test.eq!(num_water_bottles(15, 4), 19)
assert_eq!(num_water_bottles(9, 3), 13) // 9 + 3 + 1 = 13
assert_eq!(num_water_bottles(15, 4), 19)
}
```

Expand Down
4 changes: 2 additions & 2 deletions docs/02-development-environments-expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ fn num_water_bottles(num_bottles: Int, num_exchange: Int) -> Int {
// test block
test {
// statements
@test.eq!(num_water_bottles(9, 3), 13)
@test.eq!(num_water_bottles(15, 4), 19)
assert_eq!(num_water_bottles(9, 3), 13)
assert_eq!(num_water_bottles(15, 4), 19)
}
```

Expand Down
6 changes: 3 additions & 3 deletions docs/03-functions-lists-recursion.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ It is not uncommon to encounter difficulties recalling the order of parameters w

```moonbit
fn greeting1(~name: String, ~location: String) -> Unit {
println("Hi, \(name) from \(location)!")
println("Hi, \{name} from \{location}!")
}
fn init {
Expand All @@ -190,8 +190,8 @@ Consider the following example:
```moonbit
fn greeting2(~name: String, ~location: Option[String] = None) -> Unit {
match location {
Some(location) => println("Hi, \(name)!")
None => println("Hi, \(name) from \(location)!")
Some(location) => println("Hi, \{name}!")
None => println("Hi, \{name} from \{location}!")
}
}
Expand Down
6 changes: 3 additions & 3 deletions docs/12-autodiff.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ fn example() -> Symbol {
test "Symbolic differentiation" {
let input : Array[Double] = [10.0, 100.0]
let symbol : Symbol = example() // Abstract syntax tree of the function
@test.eq!(symbol.compute(input), 600.0)
assert_eq!(symbol.compute(input), 600.0)
// Expression of df/dx
inspect!(symbol.differentiate(0),
content="Add(Add(Mul(Mul(Constant(5.0), Var(0)), Constant(1.0)), Mul(Add(Mul(Constant(5.0), Constant(1.0)), Mul(Constant(0.0), Var(0))), Var(0))), Constant(0.0))")
@test.eq!(symbol.differentiate(0).compute(input), 100.0)
assert_eq!(symbol.differentiate(0).compute(input), 100.0)
}
```

Expand Down Expand Up @@ -325,7 +325,7 @@ test "Newton's method" {
}
continue Forward::var(x.value - value / derivative, true)
}
} |> @test.eq!(0.37851665401644224))
} |> assert_eq!(0.37851665401644224))
}
```

Expand Down
2 changes: 1 addition & 1 deletion docs/14-stack-machine.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ fn Program::to_wasm(self : Program, buffer : Buffer) -> Unit
fn Instruction::to_wasm(self : Instruction, buffer : Buffer) -> Unit {
match self {
Add => buffer.write_string("i32.add ")
Local_Get(val) => buffer.write_string("local.get $\(val) ")
Local_Get(val) => buffer.write_string("local.get $\{val} ")
_ => buffer.write_string("...")
}
}
Expand Down

0 comments on commit 7048bc1

Please sign in to comment.