clamp macro

This commit is contained in:
2021-10-29 13:36:46 -04:00
parent a402bc6f2c
commit 6e3d030a74
3 changed files with 38 additions and 1 deletions

View File

@@ -313,6 +313,10 @@ class BasicTestCase extends Test {
function testDotAccessOnAlias() {
_testDotAccessOnAlias();
}
function testClamp() {
_testClamp();
}
}
class BasicObject {

View File

@@ -546,4 +546,12 @@
(var float 0.5) // This should still read as a float, not a dot access on a variable called 0
(defAlias &ident owf objWithField)
(function _testDotAccessOnAlias []
(Assert.equals 5 owf.field))
(Assert.equals 5 owf.field))
(function _testClamp []
(let [&mut bigValue 12
&mut smallValue 3]
(Assert.equals 10 (clamp bigValue 5 10))
(Assert.equals 10 bigValue)
(Assert.equals 5 (clamp smallValue 5 10))
(Assert.equals 5 smallValue)))