File: Test175.ML

package info (click to toggle)
polyml 5.8.1-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 57,736 kB
  • sloc: cpp: 44,918; ansic: 26,921; asm: 13,495; sh: 4,670; makefile: 610; exp: 525; python: 253; awk: 91
file content (63 lines) | stat: -rw-r--r-- 2,265 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
(* Test122 rewritten for Real32.real. *)
fun check x = x orelse raise Fail "Test failed";

let
    val a = Real32.nextAfter(1.0, 2.0)
in
    check(a > 1.0 andalso a < 2.0)
    (* This was actually a code-generator bug. *)
end;


(* The old version of the basis library documentation said that this should
   print the digits.  That was removed before the book was published but not
   fixed in the source. *)
check(IEEEReal.toString {class = IEEEReal.NAN, sign = false, digits = [1,2,3], exp = 0} = "nan");

val pNan = valOf(Real32.fromDecimal { class = IEEEReal.NAN, sign = false, digits = [], exp = 0})
and mNan = valOf(Real32.fromDecimal { class = IEEEReal.NAN, sign = true, digits = [], exp = 0});

check(not(Real32.signBit pNan));
check(Real32.signBit mNan);

check(not(#sign(Real32.toDecimal pNan)));
check(#sign(Real32.toDecimal mNan));

check(not(Real32.signBit(abs(Real32.posInf * 0.0))));
check(not(Real32.signBit(abs(~ (Real32.posInf * 0.0)))));
check(not(Real32.signBit(Real32.abs(Real32.posInf * 0.0))));
check(not(Real32.signBit(Real32.abs(~ (Real32.posInf * 0.0)))));

check(Real32.fmt (StringCvt.SCI NONE) mNan = "nan");
check(Real32.fmt (StringCvt.FIX NONE) mNan = "nan");
check(Real32.fmt (StringCvt.GEN NONE) mNan = "nan");
check(Real32.fmt StringCvt.EXACT mNan = "nan");

check(not (Real32.isNan 0.0));
check(not (Real32.isNan ~1.0));
check(not (Real32.isNan Real32.posInf));
check(not (Real32.isNan Real32.negInf));

check (Real32.isNan pNan);
check (Real32.isNan mNan);

check(Real32.isFinite 0.0);
check(not (Real32.isFinite pNan));
check(not (Real32.isFinite mNan));
check(not (Real32.isFinite Real32.posInf));
check(not (Real32.isFinite Real32.negInf));

(* The exceptions with invalid specifications should be raised when
   Real32.fmt is applied to the spec. *)
check((Real32.fmt(StringCvt.SCI(SOME ~1)); false) handle Size => true);
check((Real32.fmt(StringCvt.FIX(SOME ~1)); false) handle Size => true);
check((Real32.fmt(StringCvt.GEN(SOME ~1)); false) handle Size => true);


check(not(Real32.unordered(1.0, 1.0)));
check(Real32.unordered(pNan, 1.0));
check(Real32.unordered(1.0, pNan));
check(Real32.unordered(pNan, pNan));
check(Real32.unordered(mNan, 1.0));
check(Real32.unordered(1.0, mNan));
check(Real32.unordered(mNan, mNan));