Skip to content

Commit 7048bc1

Browse files
authored
use assert_eq and \{..} (#49)
Co-authored-by: Haoxiang Fei <feihaoxiang@idea.edu.cn>
1 parent 21b780e commit 7048bc1

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

docs/01-program-design.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ The process of writing test cases not only helps in validating the solution but
6565

6666
```moonbit
6767
test {
68-
@test.eq!(num_water_bottles(9, 3), 13) // 9 + 3 + 1 = 13
69-
@test.eq!(num_water_bottles(15, 4), 19)
68+
assert_eq!(num_water_bottles(9, 3), 13) // 9 + 3 + 1 = 13
69+
assert_eq!(num_water_bottles(15, 4), 19)
7070
}
7171
```
7272

@@ -91,8 +91,8 @@ fn num_water_bottles(num_bottles: Int, num_exchange: Int) -> Int {
9191
}
9292
9393
test {
94-
@test.eq!(num_water_bottles(9, 3), 13) // 9 + 3 + 1 = 13
95-
@test.eq!(num_water_bottles(15, 4), 19)
94+
assert_eq!(num_water_bottles(9, 3), 13) // 9 + 3 + 1 = 13
95+
assert_eq!(num_water_bottles(15, 4), 19)
9696
}
9797
```
9898

docs/02-development-environments-expressions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ fn num_water_bottles(num_bottles: Int, num_exchange: Int) -> Int {
5858
// test block
5959
test {
6060
// statements
61-
@test.eq!(num_water_bottles(9, 3), 13)
62-
@test.eq!(num_water_bottles(15, 4), 19)
61+
assert_eq!(num_water_bottles(9, 3), 13)
62+
assert_eq!(num_water_bottles(15, 4), 19)
6363
}
6464
```
6565

docs/03-functions-lists-recursion.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ It is not uncommon to encounter difficulties recalling the order of parameters w
171171

172172
```moonbit
173173
fn greeting1(~name: String, ~location: String) -> Unit {
174-
println("Hi, \(name) from \(location)!")
174+
println("Hi, \{name} from \{location}!")
175175
}
176176
177177
fn init {
@@ -190,8 +190,8 @@ Consider the following example:
190190
```moonbit
191191
fn greeting2(~name: String, ~location: Option[String] = None) -> Unit {
192192
match location {
193-
Some(location) => println("Hi, \(name)!")
194-
None => println("Hi, \(name) from \(location)!")
193+
Some(location) => println("Hi, \{name}!")
194+
None => println("Hi, \{name} from \{location}!")
195195
}
196196
}
197197

docs/12-autodiff.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ fn example() -> Symbol {
108108
test "Symbolic differentiation" {
109109
let input : Array[Double] = [10.0, 100.0]
110110
let symbol : Symbol = example() // Abstract syntax tree of the function
111-
@test.eq!(symbol.compute(input), 600.0)
111+
assert_eq!(symbol.compute(input), 600.0)
112112
// Expression of df/dx
113113
inspect!(symbol.differentiate(0),
114114
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))")
115-
@test.eq!(symbol.differentiate(0).compute(input), 100.0)
115+
assert_eq!(symbol.differentiate(0).compute(input), 100.0)
116116
}
117117
```
118118

@@ -325,7 +325,7 @@ test "Newton's method" {
325325
}
326326
continue Forward::var(x.value - value / derivative, true)
327327
}
328-
} |> @test.eq!(0.37851665401644224))
328+
} |> assert_eq!(0.37851665401644224))
329329
}
330330
```
331331

docs/14-stack-machine.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ fn Program::to_wasm(self : Program, buffer : Buffer) -> Unit
200200
fn Instruction::to_wasm(self : Instruction, buffer : Buffer) -> Unit {
201201
match self {
202202
Add => buffer.write_string("i32.add ")
203-
Local_Get(val) => buffer.write_string("local.get $\(val) ")
203+
Local_Get(val) => buffer.write_string("local.get $\{val} ")
204204
_ => buffer.write_string("...")
205205
}
206206
}

0 commit comments

Comments
 (0)