File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -328,6 +328,13 @@ class Round extends ValueOnlyConstraint {
328
328
}
329
329
}
330
330
331
+ class Fix extends ValueOnlyConstraint {
332
+ getReturnValue ( args ) {
333
+ let x = args [ 0 ] ;
334
+ return x - x % 1 ;
335
+ }
336
+ }
337
+
331
338
class ToFixed extends TotalFunctionConstraint {
332
339
static AttributeMapping = {
333
340
"value" : 0 ,
@@ -476,6 +483,7 @@ providers.provide("pow", Pow);
476
483
providers . provide ( "random" , Random ) ;
477
484
providers . provide ( "range" , Range ) ;
478
485
providers . provide ( "round" , Round ) ;
486
+ providers . provide ( "fix" , Fix ) ;
479
487
providers . provide ( "gaussian" , Gaussian ) ;
480
488
providers . provide ( "to-fixed" , ToFixed ) ;
481
489
Original file line number Diff line number Diff line change @@ -214,12 +214,20 @@ let round_list : valueTest[] = [
214
214
]
215
215
testSingleExpressionByList ( round_list ) ;
216
216
217
- // Test Round Function
217
+ // Test To Fixed Function
218
218
let toFixed_list : valueTest [ ] = [
219
219
{ expression : "to-fixed[ value: 1.499 places: 2 ]" , expectedValue : 1.50 } ,
220
220
]
221
221
testSingleExpressionByList ( toFixed_list ) ;
222
222
223
+ // Test Fix Function
224
+ let Fix_list : valueTest [ ] = [
225
+ { expression : "fix[ value: 1.99999999999999]" , expectedValue : 1 } ,
226
+ { expression : "fix[ value: -1.99999999999999]" , expectedValue : - 1 } ,
227
+ ]
228
+ testSingleExpressionByList ( Fix_list ) ;
229
+
230
+
223
231
test ( "Test that string concatenation is still working after NaN change." , ( assert ) => {
224
232
let expected = {
225
233
insert : [
You can’t perform that action at this time.
0 commit comments