Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyfettes committed Jul 23, 2024
1 parent ffa04c7 commit 056037f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 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)!
@test.eq!(num_water_bottles(9, 3), 13) // 9 + 3 + 1 = 13
@test.eq!(num_water_bottles(15, 4), 19)
}
```

Expand All @@ -91,12 +91,12 @@ 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)!
@test.eq!(num_water_bottles(9, 3), 13) // 9 + 3 + 1 = 13
@test.eq!(num_water_bottles(15, 4), 19)
}
```

The program can be verified by executing it [here](https://try.moonbitlang.com/#f9b7f68d). If there is no output, it indicates that the program has performed as expected. Alternatively, if we modify the test cases and then rerun the program, an error might be observed.
The program can be verified by executing it [here](https://try.moonbitlang.com/#79f7b666). If there is no output, it indicates that the program has performed as expected. Alternatively, if we modify the test cases and then rerun the program, an error might be observed.

### Summary

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)!
@test.eq!(num_water_bottles(9, 3), 13)
@test.eq!(num_water_bottles(15, 4), 19)
}
```

Expand Down
8 changes: 4 additions & 4 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)!
@test.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)!
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)
}
```

Expand Down

0 comments on commit 056037f

Please sign in to comment.