add acceptance test 88
This commit is contained in:
13
examples/acceptance_tests/088/aiken.lock
Normal file
13
examples/acceptance_tests/088/aiken.lock
Normal file
@@ -0,0 +1,13 @@
|
||||
# This file was generated by Aiken
|
||||
# You typically do not need to edit this file
|
||||
|
||||
[[requirements]]
|
||||
name = "aiken-lang/stdlib"
|
||||
version = "main"
|
||||
source = "github"
|
||||
|
||||
[[packages]]
|
||||
name = "aiken-lang/stdlib"
|
||||
version = "main"
|
||||
requirements = []
|
||||
source = "github"
|
||||
8
examples/acceptance_tests/088/aiken.toml
Normal file
8
examples/acceptance_tests/088/aiken.toml
Normal file
@@ -0,0 +1,8 @@
|
||||
name = "aiken-lang/acceptance_test_088"
|
||||
version = "0.0.0"
|
||||
description = ""
|
||||
|
||||
[[dependencies]]
|
||||
name = 'aiken-lang/stdlib'
|
||||
version = 'main'
|
||||
source = 'github'
|
||||
32
examples/acceptance_tests/088/lib/tests.ak
Normal file
32
examples/acceptance_tests/088/lib/tests.ak
Normal file
@@ -0,0 +1,32 @@
|
||||
use aiken/math/rational.{Rational}
|
||||
use aiken/option
|
||||
|
||||
pub fn div_by_int_orig(rat: Rational, token_2_amount: Int) -> Option<Int> {
|
||||
rational.div(
|
||||
rat,
|
||||
token_2_amount
|
||||
|> rational.from_int,
|
||||
)
|
||||
|> option.map(rational.truncate)
|
||||
}
|
||||
|
||||
pub fn div_by_int_fixed(rat: Rational, token_2_amount: Int) -> Option<Int> {
|
||||
when
|
||||
rational.div(
|
||||
rat,
|
||||
token_2_amount
|
||||
|> rational.from_int,
|
||||
)
|
||||
is {
|
||||
Some(rat) -> Some(rational.truncate(rat))
|
||||
None -> None
|
||||
}
|
||||
}
|
||||
|
||||
test sale_failing_test() {
|
||||
div_by_int_orig(100 |> rational.from_int, 100) == Some(1)
|
||||
}
|
||||
|
||||
test sale_fixed_test() {
|
||||
div_by_int_fixed(100 |> rational.from_int, 100) == Some(1)
|
||||
}
|
||||
Reference in New Issue
Block a user