1
0
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:
Chayim Refael Friedman
2021-04-08 08:04:58 +03:00
committed by GitHub
parent 4847b37789
commit 68f5c096d8
7 changed files with 18 additions and 0 deletions

View File

@ -0,0 +1 @@
0.atan(false) // expect runtime error: x value must be a number.

View File

@ -0,0 +1 @@
1.clamp(0, false) // expect runtime error: Max value must be a number.

View File

@ -0,0 +1 @@
1.clamp(false, 2) // expect runtime error: Min value must be a number.

View File

@ -0,0 +1 @@
1.max(false) // expect runtime error: Other value must be a number.

View File

@ -0,0 +1 @@
1.min(false) // expect runtime error: Other value must be a number.

View File

@ -0,0 +1,2 @@
1.pow(false) // expect runtime error: Power value must be a number.