forked from Mirror/wren
Disallow non-Num arguments in Num for min(_), max(_), clamp(_,_), pow(_) and atan(_) (#859)
* Disallow non-Num arguments in `Num.min(_)`, `Num.max(_)`, `Num.clamp(_,_)` Previously this was an Undefined Behavior * also validate args for pow, atan2, add tests, fix error messages Co-authored-by: ruby0x1 <ruby0x1@pm.me>
This commit is contained in:
committed by
GitHub
parent
4847b37789
commit
68f5c096d8
1
test/core/number/atan2_x_not_num.wren
Normal file
1
test/core/number/atan2_x_not_num.wren
Normal file
@ -0,0 +1 @@
|
||||
0.atan(false) // expect runtime error: x value must be a number.
|
||||
1
test/core/number/clamp_max_not_num.wren
Normal file
1
test/core/number/clamp_max_not_num.wren
Normal file
@ -0,0 +1 @@
|
||||
1.clamp(0, false) // expect runtime error: Max value must be a number.
|
||||
1
test/core/number/clamp_min_not_num.wren
Normal file
1
test/core/number/clamp_min_not_num.wren
Normal file
@ -0,0 +1 @@
|
||||
1.clamp(false, 2) // expect runtime error: Min value must be a number.
|
||||
1
test/core/number/max_other_not_num.wren
Normal file
1
test/core/number/max_other_not_num.wren
Normal file
@ -0,0 +1 @@
|
||||
1.max(false) // expect runtime error: Other value must be a number.
|
||||
1
test/core/number/min_other_not_num.wren
Normal file
1
test/core/number/min_other_not_num.wren
Normal file
@ -0,0 +1 @@
|
||||
1.min(false) // expect runtime error: Other value must be a number.
|
||||
2
test/core/number/pow_power_not_num.wren
Normal file
2
test/core/number/pow_power_not_num.wren
Normal file
@ -0,0 +1,2 @@
|
||||
1.pow(false) // expect runtime error: Power value must be a number.
|
||||
|
||||
Reference in New Issue
Block a user