|
Revision 2592, 0.8 KB
(checked in by Charles.Esterbrook, 9 months ago)
|
|
JVM back-end progress, courtesy of hopscc.
credit:hopscc
|
-
Property svn:eol-style set to
native
|
| Line | |
|---|
| 1 | #.require. clr |
|---|
| 2 | # revisit this for Java when decide and implement what to do about Decimal Type |
|---|
| 3 | namespace Test |
|---|
| 4 | |
|---|
| 5 | class Test |
|---|
| 6 | |
|---|
| 7 | def main |
|---|
| 8 | is shared |
|---|
| 9 | |
|---|
| 10 | d as decimal = 1.0 |
|---|
| 11 | assert d |
|---|
| 12 | assert d==1.0 |
|---|
| 13 | assert d==1 |
|---|
| 14 | assert d==1d |
|---|
| 15 | |
|---|
| 16 | d = 1 |
|---|
| 17 | assert d == 1.0 |
|---|
| 18 | |
|---|
| 19 | d = 1d |
|---|
| 20 | assert d == 1.0 |
|---|
| 21 | |
|---|
| 22 | # this simple test, with only 10 additions, would fail for float64 |
|---|
| 23 | sum as decimal = 0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1 |
|---|
| 24 | assert sum==1.0 |
|---|
| 25 | # and this one too: |
|---|
| 26 | assert sum==0.1*10 |
|---|
| 27 | |
|---|
| 28 | assert 1.0 inherits decimal # .warning. is always |
|---|
| 29 | assert 1 inherits int # .warning. is always |
|---|
| 30 | assert not (1 inherits decimal) # .warning. is never |
|---|
| 31 | |
|---|
| 32 | # can use the 'd' suffix to be explicit |
|---|
| 33 | assert 1.0d == 1.0 |
|---|
| 34 | |
|---|
| 35 | # can assign ints to decimals |
|---|
| 36 | d = 7 |
|---|
| 37 | |
|---|
| 38 | # can compare ints and decimals |
|---|
| 39 | assert d > 0 |
|---|
| 40 | assert 0 < d |
|---|