|
| 1 | +Rebol [ |
| 2 | + Title: "Rebol3 decimal test script" |
| 3 | + Author: "Oldes, Peter W A Wood" |
| 4 | + File: %decimal-test.r3 |
| 5 | + Tabs: 4 |
| 6 | + Needs: [%../quick-test-module.r3] |
| 7 | +] |
| 8 | + |
| 9 | + |
| 10 | +~~~start-file~~~ "decimal" |
| 11 | + |
| 12 | +===start-group=== "round" |
| 13 | + --test-- "round" |
| 14 | + --assert 1.0 = round 1.4999 |
| 15 | + --assert 2.0 = round 1.5 |
| 16 | + --assert -2.0 = round -1.5 |
| 17 | + |
| 18 | + --test-- "round/to (decimal)" |
| 19 | + --assert 1.375 = round/to 1.333 .125 |
| 20 | + --assert 1.33 = round/to 1.333 .01 |
| 21 | + |
| 22 | + --test-- "round/to (integer)" |
| 23 | + --assert 1 = round/to 0.5 1 |
| 24 | + --assert 0 = round/to 0.499 1 |
| 25 | + --assert integer? round/to 0.5 1 |
| 26 | + |
| 27 | + --test-- "round/to (money)" |
| 28 | + --assert $1 = round/to 0.5 $1 |
| 29 | + --assert $0 = round/to 0.499 $1 |
| 30 | + --assert money? round/to 0.5 $1 |
| 31 | + |
| 32 | + --test-- "round/down" |
| 33 | + --assert 1.0 = round/down 1.999 |
| 34 | + --assert -1.0 = round/down -1.999 |
| 35 | + |
| 36 | + --test-- "round/even" |
| 37 | + --assert 2.0 = round/even 1.5 |
| 38 | + --assert -2.0 = round/even -1.5 |
| 39 | + |
| 40 | + --test-- "round/half-down" |
| 41 | + --assert 1.0 = round/half-down 1.5 |
| 42 | + --assert -1.0 = round/half-down -1.5 |
| 43 | + |
| 44 | + --test-- "round/floor" |
| 45 | + --assert 1.0 = round/floor 1.999 |
| 46 | + --assert -2.0 = round/floor -1.0000001 |
| 47 | + |
| 48 | + --test-- "round/ceiling" |
| 49 | + --assert 2.0 = round/ceiling 1.0000001 |
| 50 | + --assert -1.0 = round/ceiling -1.999 |
| 51 | + |
| 52 | + --test-- "round/half-ceiling" |
| 53 | + --assert 2.0 = round/half-ceiling 1.5 |
| 54 | + --assert -1.0 = round/half-ceiling -1.5 |
| 55 | + |
| 56 | +===end-group=== |
| 57 | + |
| 58 | +~~~end-file~~~ |
0 commit comments