forked from Mirror/wren
Num; add min, max and clamp
This commit is contained in:
7
test/core/number/clamp.wren
Normal file
7
test/core/number/clamp.wren
Normal file
@ -0,0 +1,7 @@
|
||||
var num = 4
|
||||
|
||||
System.print(num.clamp(0, 10)) // expect: 4
|
||||
System.print(num.clamp(0, 1)) // expect: 1
|
||||
System.print(2.clamp(0, 1)) // expect: 1
|
||||
System.print((-1).clamp(0, 1)) // expect: 0
|
||||
System.print((-1).clamp(-20, 0)) // expect: -1
|
||||
5
test/core/number/min_max.wren
Normal file
5
test/core/number/min_max.wren
Normal file
@ -0,0 +1,5 @@
|
||||
var num = 4
|
||||
var num2 = 6
|
||||
|
||||
System.print(num.max(num2)) // expect: 6
|
||||
System.print(num.min(num2)) // expect: 4
|
||||
Reference in New Issue
Block a user