Tcl Source Code

Hex Artifact Content
Login

Artifact 51c0379b676d0e59754340420915aa5211d06e28:

Attachment "expr27.tcl" to ticket [761471ffff] added by kennykb 2004-11-06 03:21:51.
0000: 23 20 42 69 67 20 74 65 73 74 20 66 6f 72 20 63  # Big test for c
0010: 6f 72 72 65 63 74 20 6f 72 64 65 72 69 6e 67 20  orrect ordering 
0020: 6f 66 20 64 61 74 61 20 69 6e 20 5b 65 78 70 72  of data in [expr
0030: 5d 0a 0a 70 72 6f 63 20 74 65 73 74 49 45 45 45  ]..proc testIEEE
0040: 20 7b 7d 20 7b 0a 20 20 20 20 76 61 72 69 61 62   {} {.    variab
0050: 6c 65 20 69 65 65 65 56 61 6c 75 65 73 0a 20 20  le ieeeValues.  
0060: 20 20 62 69 6e 61 72 79 20 73 63 61 6e 20 5b 62    binary scan [b
0070: 69 6e 61 72 79 20 66 6f 72 6d 61 74 20 64 64 20  inary format dd 
0080: 2d 31 2e 30 20 31 2e 30 5d 20 63 2a 20 63 0a 20  -1.0 1.0] c* c. 
0090: 20 20 20 73 77 69 74 63 68 20 2d 65 78 61 63 74     switch -exact
00a0: 20 24 63 20 7b 0a 09 7b 30 20 30 20 30 20 30 20   $c {..{0 0 0 0 
00b0: 30 20 30 20 2d 31 36 20 2d 36 35 20 30 20 30 20  0 0 -16 -65 0 0 
00c0: 30 20 30 20 30 20 30 20 2d 31 36 20 36 33 7d 20  0 0 0 0 -16 63} 
00d0: 7b 0a 09 20 20 20 20 62 69 6e 61 72 79 20 73 63  {..    binary sc
00e0: 61 6e 20 5c 78 30 30 5c 78 30 30 5c 78 30 30 5c  an \x00\x00\x00\
00f0: 78 30 30 5c 78 30 30 5c 78 30 30 5c 78 66 30 5c  x00\x00\x00\xf0\
0100: 78 66 66 20 64 20 5c 0a 09 09 69 65 65 65 56 61  xff d \...ieeeVa
0110: 6c 75 65 73 28 2d 49 6e 66 69 6e 69 74 79 29 0a  lues(-Infinity).
0120: 09 20 20 20 20 62 69 6e 61 72 79 20 73 63 61 6e  .    binary scan
0130: 20 5c 78 30 30 5c 78 30 30 5c 78 30 30 5c 78 30   \x00\x00\x00\x0
0140: 30 5c 78 30 30 5c 78 30 30 5c 78 66 30 5c 78 62  0\x00\x00\xf0\xb
0150: 66 20 64 20 5c 0a 09 09 69 65 65 65 56 61 6c 75  f d \...ieeeValu
0160: 65 73 28 2d 4e 6f 72 6d 61 6c 29 0a 09 20 20 20  es(-Normal)..   
0170: 20 62 69 6e 61 72 79 20 73 63 61 6e 20 5c 78 30   binary scan \x0
0180: 30 5c 78 30 30 5c 78 30 30 5c 78 30 30 5c 78 30  0\x00\x00\x00\x0
0190: 30 5c 78 30 30 5c 78 30 38 5c 78 38 30 20 64 20  0\x00\x08\x80 d 
01a0: 5c 0a 09 09 69 65 65 65 56 61 6c 75 65 73 28 2d  \...ieeeValues(-
01b0: 53 75 62 6e 6f 72 6d 61 6c 29 0a 09 20 20 20 20  Subnormal)..    
01c0: 62 69 6e 61 72 79 20 73 63 61 6e 20 5c 78 30 30  binary scan \x00
01d0: 5c 78 30 30 5c 78 30 30 5c 78 30 30 5c 78 30 30  \x00\x00\x00\x00
01e0: 5c 78 30 30 5c 78 30 30 5c 78 38 30 20 64 20 5c  \x00\x00\x80 d \
01f0: 0a 09 09 69 65 65 65 56 61 6c 75 65 73 28 2d 30  ...ieeeValues(-0
0200: 29 0a 09 20 20 20 20 62 69 6e 61 72 79 20 73 63  )..    binary sc
0210: 61 6e 20 5c 78 30 30 5c 78 30 30 5c 78 30 30 5c  an \x00\x00\x00\
0220: 78 30 30 5c 78 30 30 5c 78 30 30 5c 78 30 30 5c  x00\x00\x00\x00\
0230: 78 30 30 20 64 20 5c 0a 09 09 69 65 65 65 56 61  x00 d \...ieeeVa
0240: 6c 75 65 73 28 2b 30 29 0a 09 20 20 20 20 62 69  lues(+0)..    bi
0250: 6e 61 72 79 20 73 63 61 6e 20 5c 78 30 30 5c 78  nary scan \x00\x
0260: 30 30 5c 78 30 30 5c 78 30 30 5c 78 30 30 5c 78  00\x00\x00\x00\x
0270: 30 30 5c 30 38 30 5c 78 30 30 20 64 20 5c 0a 09  00\080\x00 d \..
0280: 09 69 65 65 65 56 61 6c 75 65 73 28 2b 53 75 62  .ieeeValues(+Sub
0290: 6e 6f 72 6d 61 6c 29 0a 09 20 20 20 20 62 69 6e  normal)..    bin
02a0: 61 72 79 20 73 63 61 6e 20 5c 78 30 30 5c 78 30  ary scan \x00\x0
02b0: 30 5c 78 30 30 5c 78 30 30 5c 78 30 30 5c 78 30  0\x00\x00\x00\x0
02c0: 30 5c 78 66 30 5c 78 33 66 20 64 20 5c 0a 09 09  0\xf0\x3f d \...
02d0: 69 65 65 65 56 61 6c 75 65 73 28 2b 4e 6f 72 6d  ieeeValues(+Norm
02e0: 61 6c 29 0a 09 20 20 20 20 62 69 6e 61 72 79 20  al)..    binary 
02f0: 73 63 61 6e 20 5c 78 30 30 5c 78 30 30 5c 78 30  scan \x00\x00\x0
0300: 30 5c 78 30 30 5c 78 30 30 5c 78 30 30 5c 78 66  0\x00\x00\x00\xf
0310: 30 5c 78 37 66 20 64 20 5c 0a 09 09 69 65 65 65  0\x7f d \...ieee
0320: 56 61 6c 75 65 73 28 2b 49 6e 66 69 6e 69 74 79  Values(+Infinity
0330: 29 0a 09 20 20 20 20 62 69 6e 61 72 79 20 73 63  )..    binary sc
0340: 61 6e 20 5c 78 30 30 5c 78 30 30 5c 78 30 30 5c  an \x00\x00\x00\
0350: 78 30 30 5c 30 78 78 5c 30 78 78 5c 78 66 38 5c  x00\0xx\0xx\xf8\
0360: 78 37 66 20 64 20 5c 0a 09 09 69 65 65 65 56 61  x7f d \...ieeeVa
0370: 6c 75 65 73 28 4e 61 4e 29 0a 09 20 20 20 20 72  lues(NaN)..    r
0380: 65 74 75 72 6e 20 31 0a 09 7d 0a 09 7b 2d 36 35  eturn 1..}..{-65
0390: 20 2d 31 36 20 30 20 30 20 30 20 30 20 30 20 30   -16 0 0 0 0 0 0
03a0: 20 36 33 20 2d 31 36 20 30 20 30 20 30 20 30 20   63 -16 0 0 0 0 
03b0: 30 20 30 7d 20 7b 0a 09 20 20 20 20 62 69 6e 61  0 0} {..    bina
03c0: 72 79 20 73 63 61 6e 20 5c 78 66 66 5c 78 66 30  ry scan \xff\xf0
03d0: 5c 78 30 30 5c 78 30 30 5c 78 30 30 5c 78 30 30  \x00\x00\x00\x00
03e0: 5c 78 30 30 5c 78 30 30 20 64 20 5c 0a 09 09 69  \x00\x00 d \...i
03f0: 65 65 65 56 61 6c 75 65 73 28 2d 49 6e 66 69 6e  eeeValues(-Infin
0400: 69 74 79 29 0a 09 20 20 20 20 62 69 6e 61 72 79  ity)..    binary
0410: 20 73 63 61 6e 20 5c 78 62 66 5c 78 66 30 5c 78   scan \xbf\xf0\x
0420: 30 30 5c 78 30 30 5c 78 30 30 5c 78 30 30 5c 78  00\x00\x00\x00\x
0430: 30 30 5c 78 30 30 20 64 20 5c 0a 09 09 69 65 65  00\x00 d \...iee
0440: 65 56 61 6c 75 65 73 28 2d 4e 6f 72 6d 61 6c 29  eValues(-Normal)
0450: 0a 09 20 20 20 20 62 69 6e 61 72 79 20 73 63 61  ..    binary sca
0460: 6e 20 5c 78 38 30 5c 78 30 38 5c 78 30 30 5c 78  n \x80\x08\x00\x
0470: 30 30 5c 78 30 30 5c 78 30 30 5c 78 30 30 5c 78  00\x00\x00\x00\x
0480: 30 30 20 64 20 5c 0a 09 09 69 65 65 65 56 61 6c  00 d \...ieeeVal
0490: 75 65 73 28 2d 53 75 62 6e 6f 72 6d 61 6c 29 0a  ues(-Subnormal).
04a0: 09 20 20 20 20 62 69 6e 61 72 79 20 73 63 61 6e  .    binary scan
04b0: 20 5c 78 38 30 5c 78 30 30 5c 78 30 30 5c 78 30   \x80\x00\x00\x0
04c0: 30 5c 78 30 30 5c 78 30 30 5c 78 30 30 5c 78 30  0\x00\x00\x00\x0
04d0: 30 20 64 20 5c 0a 09 09 69 65 65 65 56 61 6c 75  0 d \...ieeeValu
04e0: 65 73 28 2d 30 29 0a 09 20 20 20 20 62 69 6e 61  es(-0)..    bina
04f0: 72 79 20 73 63 61 6e 20 5c 78 30 30 5c 78 30 30  ry scan \x00\x00
0500: 5c 78 30 30 5c 78 30 30 5c 78 30 30 5c 78 30 30  \x00\x00\x00\x00
0510: 5c 78 30 30 5c 78 30 30 20 64 20 5c 0a 09 09 69  \x00\x00 d \...i
0520: 65 65 65 56 61 6c 75 65 73 28 2b 30 29 0a 09 20  eeeValues(+0).. 
0530: 20 20 20 62 69 6e 61 72 79 20 73 63 61 6e 20 5c     binary scan \
0540: 78 30 30 5c 78 38 30 5c 78 30 30 5c 78 30 30 5c  x00\x80\x00\x00\
0550: 78 30 30 5c 78 30 30 5c 78 30 30 5c 78 30 30 20  x00\x00\x00\x00 
0560: 64 20 5c 0a 09 09 69 65 65 65 56 61 6c 75 65 73  d \...ieeeValues
0570: 28 2b 53 75 62 6e 6f 72 6d 61 6c 29 0a 09 20 20  (+Subnormal)..  
0580: 20 20 62 69 6e 61 72 79 20 73 63 61 6e 20 5c 78    binary scan \x
0590: 33 66 5c 78 66 30 5c 78 30 30 5c 78 30 30 5c 78  3f\xf0\x00\x00\x
05a0: 30 30 5c 78 30 30 5c 78 30 30 5c 78 30 30 20 64  00\x00\x00\x00 d
05b0: 20 5c 0a 09 09 69 65 65 65 56 61 6c 75 65 73 28   \...ieeeValues(
05c0: 2b 4e 6f 72 6d 61 6c 29 0a 09 20 20 20 20 62 69  +Normal)..    bi
05d0: 6e 61 72 79 20 73 63 61 6e 20 5c 78 37 66 5c 78  nary scan \x7f\x
05e0: 66 30 5c 78 30 30 5c 78 30 30 5c 78 30 30 5c 78  f0\x00\x00\x00\x
05f0: 30 30 5c 78 30 30 5c 78 30 30 20 64 20 5c 0a 09  00\x00\x00 d \..
0600: 09 69 65 65 65 56 61 6c 75 65 73 28 2b 49 6e 66  .ieeeValues(+Inf
0610: 69 6e 69 74 79 29 0a 09 20 20 20 20 62 69 6e 61  inity)..    bina
0620: 72 79 20 73 63 61 6e 20 5c 78 37 66 5c 78 66 38  ry scan \x7f\xf8
0630: 5c 78 30 30 5c 78 30 30 5c 78 30 30 5c 78 30 30  \x00\x00\x00\x00
0640: 5c 78 30 30 5c 78 30 30 20 64 20 5c 0a 09 09 69  \x00\x00 d \...i
0650: 65 65 65 56 61 6c 75 65 73 28 4e 61 4e 29 0a 09  eeeValues(NaN)..
0660: 20 20 20 20 72 65 74 75 72 6e 20 31 0a 09 7d 0a      return 1..}.
0670: 09 64 65 66 61 75 6c 74 20 7b 0a 09 20 20 20 20  .default {..    
0680: 72 65 74 75 72 6e 20 30 0a 09 7d 0a 20 20 20 20  return 0..}.    
0690: 7d 0a 7d 0a 3a 3a 74 63 6c 74 65 73 74 3a 3a 74  }.}.::tcltest::t
06a0: 65 73 74 43 6f 6e 73 74 72 61 69 6e 74 20 69 65  estConstraint ie
06b0: 65 65 46 6c 6f 61 74 69 6e 67 50 6f 69 6e 74 20  eeFloatingPoint 
06c0: 5b 74 65 73 74 49 45 45 45 5d 0a 0a 66 6f 72 65  [testIEEE]..fore
06d0: 61 63 68 20 6f 70 20 7b 3c 20 3c 3d 20 3d 3d 20  ach op {< <= == 
06e0: 21 3d 20 3e 20 3e 3d 7d 20 7b 0a 20 20 20 20 70  != > >=} {.    p
06f0: 72 6f 63 20 74 65 73 74 24 6f 70 20 7b 61 20 62  roc test$op {a b
0700: 7d 20 5b 6c 69 73 74 20 65 78 70 72 20 22 5c 24  } [list expr "\$
0710: 61 20 24 6f 70 20 5c 24 62 22 5d 0a 0a 7d 0a 0a  a $op \$b"]..}..
0720: 74 65 73 74 20 65 78 70 72 2d 32 37 2e 31 20 7b  test expr-27.1 {
0730: 65 78 70 72 20 2d 20 63 6f 72 72 65 63 74 20 6f  expr - correct o
0740: 72 64 65 72 69 6e 67 20 2d 20 6e 6f 74 20 63 6f  rdering - not co
0750: 6d 70 69 6c 65 64 7d 20 69 65 65 65 46 6c 6f 61  mpiled} ieeeFloa
0760: 74 69 6e 67 50 6f 69 6e 74 20 7b 0a 20 20 20 20  tingPoint {.    
0770: 73 65 74 20 70 72 6f 62 6c 65 6d 73 20 7b 7d 0a  set problems {}.
0780: 20 20 20 20 23 20 4f 72 64 65 72 69 6e 67 20 73      # Ordering s
0790: 68 6f 75 6c 64 20 62 65 3a 20 2d 49 6e 66 69 6e  hould be: -Infin
07a0: 69 74 79 20 3c 20 2d 4e 6f 72 6d 61 6c 20 3c 20  ity < -Normal < 
07b0: 53 75 62 6e 6f 72 6d 61 6c 20 3c 20 2d 30 0a 20  Subnormal < -0. 
07c0: 20 20 20 23 20 20 20 20 20 20 20 20 20 20 20 20     #            
07d0: 20 20 20 20 20 20 20 20 20 3c 20 2b 30 20 3c 20           < +0 < 
07e0: 2b 53 75 62 6e 6f 72 6d 61 6c 20 3c 20 2b 4e 6f  +Subnormal < +No
07f0: 72 6d 61 6c 20 3c 20 2b 49 6e 66 69 6e 69 74 79  rmal < +Infinity
0800: 0a 20 20 20 20 23 20 77 69 74 68 20 65 71 75 61  .    # with equa
0810: 6c 69 74 79 20 77 69 74 68 69 6e 20 65 61 63 68  lity within each
0820: 20 63 6c 61 73 73 2e 0a 20 20 20 20 73 65 74 20   class..    set 
0830: 6e 61 6d 65 73 20 7b 0a 09 2d 49 6e 66 69 6e 69  names {..-Infini
0840: 74 79 20 2d 4e 6f 72 6d 61 6c 20 2d 53 75 62 6e  ty -Normal -Subn
0850: 6f 72 6d 61 6c 20 2d 30 20 2b 30 20 2b 53 75 62  ormal -0 +0 +Sub
0860: 6e 6f 72 6d 61 6c 20 2b 4e 6f 72 6d 61 6c 20 2b  normal +Normal +
0870: 49 6e 66 69 6e 69 74 79 0a 20 20 20 20 7d 0a 20  Infinity.    }. 
0880: 20 20 20 73 65 74 20 77 65 69 67 68 74 73 20 7b     set weights {
0890: 0a 09 2d 33 20 2d 32 20 2d 31 20 30 20 30 20 31  ..-3 -2 -1 0 0 1
08a0: 20 32 20 33 0a 20 20 20 20 7d 0a 20 20 20 20 66   2 3.    }.    f
08b0: 6f 72 65 61 63 68 20 6e 61 6d 65 31 20 24 6e 61  oreach name1 $na
08c0: 6d 65 73 20 77 65 69 67 68 74 31 20 24 77 65 69  mes weight1 $wei
08d0: 67 68 74 73 20 7b 0a 09 66 6f 72 65 61 63 68 20  ghts {..foreach 
08e0: 6e 61 6d 65 32 20 24 6e 61 6d 65 73 20 77 65 69  name2 $names wei
08f0: 67 68 74 32 20 24 77 65 69 67 68 74 73 20 7b 0a  ght2 $weights {.
0900: 09 20 20 20 20 66 6f 72 65 61 63 68 20 6f 70 20  .    foreach op 
0910: 7b 3c 20 3c 3d 20 3d 3d 20 21 3d 20 3e 3d 20 3e  {< <= == != >= >
0920: 7d 20 7b 0a 09 09 73 65 74 20 73 68 6f 75 6c 64  } {...set should
0930: 42 65 20 5b 65 78 70 72 20 22 24 77 65 69 67 68  Be [expr "$weigh
0940: 74 31 20 24 6f 70 20 24 77 65 69 67 68 74 32 22  t1 $op $weight2"
0950: 5d 0a 09 09 73 65 74 20 69 73 20 5b 65 78 70 72  ]...set is [expr
0960: 20 22 5c 24 69 65 65 65 56 61 6c 75 65 73 28 24   "\$ieeeValues($
0970: 6e 61 6d 65 31 29 20 24 6f 70 20 5c 24 69 65 65  name1) $op \$iee
0980: 65 56 61 6c 75 65 73 28 24 6e 61 6d 65 32 29 22  eValues($name2)"
0990: 5d 0a 09 09 69 66 20 7b 20 24 69 73 20 21 3d 20  ]...if { $is != 
09a0: 24 73 68 6f 75 6c 64 42 65 20 7d 20 7b 0a 09 09  $shouldBe } {...
09b0: 20 20 20 20 61 70 70 65 6e 64 20 70 72 6f 62 6c      append probl
09c0: 65 6d 73 20 24 6e 61 6d 65 31 20 7b 20 7d 20 24  ems $name1 { } $
09d0: 6f 70 20 7b 20 7d 20 24 6e 61 6d 65 32 20 5c 0a  op { } $name2 \.
09e0: 09 09 09 22 3a 72 65 73 75 6c 74 20 69 73 20 22  ...":result is "
09f0: 20 24 69 73 20 22 2c 20 73 68 6f 75 6c 64 20 62   $is ", should b
0a00: 65 20 24 73 68 6f 75 6c 64 42 65 22 20 5c 6e 0a  e $shouldBe" \n.
0a10: 09 09 7d 0a 09 20 20 20 20 7d 0a 09 7d 0a 20 20  ..}..    }..}.  
0a20: 20 20 7d 0a 20 20 20 20 73 65 74 20 70 72 6f 62    }.    set prob
0a30: 6c 65 6d 73 0a 7d 20 7b 7d 0a 0a 74 65 73 74 20  lems.} {}..test 
0a40: 65 78 70 72 2d 32 37 2e 32 20 7b 65 78 70 72 20  expr-27.2 {expr 
0a50: 2d 20 63 6f 72 72 65 63 74 20 6f 72 64 65 72 69  - correct orderi
0a60: 6e 67 20 2d 20 63 6f 6d 70 69 6c 65 64 7d 20 69  ng - compiled} i
0a70: 65 65 65 46 6c 6f 61 74 69 6e 67 50 6f 69 6e 74  eeeFloatingPoint
0a80: 20 7b 0a 20 20 20 20 73 65 74 20 70 72 6f 62 6c   {.    set probl
0a90: 65 6d 73 20 7b 7d 0a 20 20 20 20 23 20 4f 72 64  ems {}.    # Ord
0aa0: 65 72 69 6e 67 20 73 68 6f 75 6c 64 20 62 65 3a  ering should be:
0ab0: 20 2d 49 6e 66 69 6e 69 74 79 20 3c 20 2d 4e 6f   -Infinity < -No
0ac0: 72 6d 61 6c 20 3c 20 53 75 62 6e 6f 72 6d 61 6c  rmal < Subnormal
0ad0: 20 3c 20 2d 30 0a 20 20 20 20 23 20 20 20 20 20   < -0.    #     
0ae0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0af0: 3c 20 2b 30 20 3c 20 2b 53 75 62 6e 6f 72 6d 61  < +0 < +Subnorma
0b00: 6c 20 3c 20 2b 4e 6f 72 6d 61 6c 20 3c 20 2b 49  l < +Normal < +I
0b10: 6e 66 69 6e 69 74 79 0a 20 20 20 20 23 20 77 69  nfinity.    # wi
0b20: 74 68 20 65 71 75 61 6c 69 74 79 20 77 69 74 68  th equality with
0b30: 69 6e 20 65 61 63 68 20 63 6c 61 73 73 2e 0a 20  in each class.. 
0b40: 20 20 20 73 65 74 20 6e 61 6d 65 73 20 7b 0a 09     set names {..
0b50: 2d 49 6e 66 69 6e 69 74 79 20 2d 4e 6f 72 6d 61  -Infinity -Norma
0b60: 6c 20 2d 53 75 62 6e 6f 72 6d 61 6c 20 2d 30 20  l -Subnormal -0 
0b70: 2b 30 20 2b 53 75 62 6e 6f 72 6d 61 6c 20 2b 4e  +0 +Subnormal +N
0b80: 6f 72 6d 61 6c 20 2b 49 6e 66 69 6e 69 74 79 0a  ormal +Infinity.
0b90: 20 20 20 20 7d 0a 20 20 20 20 73 65 74 20 77 65      }.    set we
0ba0: 69 67 68 74 73 20 7b 0a 09 2d 33 20 2d 32 20 2d  ights {..-3 -2 -
0bb0: 31 20 30 20 30 20 31 20 32 20 33 0a 20 20 20 20  1 0 0 1 2 3.    
0bc0: 7d 0a 20 20 20 20 66 6f 72 65 61 63 68 20 6e 61  }.    foreach na
0bd0: 6d 65 31 20 24 6e 61 6d 65 73 20 77 65 69 67 68  me1 $names weigh
0be0: 74 31 20 24 77 65 69 67 68 74 73 20 7b 0a 09 66  t1 $weights {..f
0bf0: 6f 72 65 61 63 68 20 6e 61 6d 65 32 20 24 6e 61  oreach name2 $na
0c00: 6d 65 73 20 77 65 69 67 68 74 32 20 24 77 65 69  mes weight2 $wei
0c10: 67 68 74 73 20 7b 0a 09 20 20 20 20 66 6f 72 65  ghts {..    fore
0c20: 61 63 68 20 6f 70 20 7b 3c 20 3c 3d 20 3d 3d 20  ach op {< <= == 
0c30: 21 3d 20 3e 3d 20 3e 7d 20 7b 0a 09 09 73 65 74  != >= >} {...set
0c40: 20 73 68 6f 75 6c 64 42 65 20 5b 65 78 70 72 20   shouldBe [expr 
0c50: 22 24 77 65 69 67 68 74 31 20 24 6f 70 20 24 77  "$weight1 $op $w
0c60: 65 69 67 68 74 32 22 5d 0a 09 09 73 65 74 20 69  eight2"]...set i
0c70: 73 20 5b 74 65 73 74 24 6f 70 20 24 69 65 65 65  s [test$op $ieee
0c80: 56 61 6c 75 65 73 28 24 6e 61 6d 65 31 29 20 24  Values($name1) $
0c90: 69 65 65 65 56 61 6c 75 65 73 28 24 6e 61 6d 65  ieeeValues($name
0ca0: 32 29 5d 0a 09 09 69 66 20 7b 20 24 69 73 20 21  2)]...if { $is !
0cb0: 3d 20 24 73 68 6f 75 6c 64 42 65 20 7d 20 7b 0a  = $shouldBe } {.
0cc0: 09 09 20 20 20 20 61 70 70 65 6e 64 20 70 72 6f  ..    append pro
0cd0: 62 6c 65 6d 73 20 24 6e 61 6d 65 31 20 7b 20 7d  blems $name1 { }
0ce0: 20 24 6f 70 20 7b 20 7d 20 24 6e 61 6d 65 32 20   $op { } $name2 
0cf0: 5c 0a 09 09 09 22 3a 72 65 73 75 6c 74 20 69 73  \....":result is
0d00: 20 22 20 24 69 73 20 22 2c 20 73 68 6f 75 6c 64   " $is ", should
0d10: 20 62 65 20 24 73 68 6f 75 6c 64 42 65 22 20 5c   be $shouldBe" \
0d20: 6e 0a 09 09 7d 0a 09 20 20 20 20 7d 0a 09 7d 0a  n...}..    }..}.
0d30: 20 20 20 20 7d 0a 20 20 20 20 73 65 74 20 70 72      }.    set pr
0d40: 6f 62 6c 65 6d 73 0a 7d 20 7b 7d 0a 0a 74 65 73  oblems.} {}..tes
0d50: 74 20 65 78 70 72 2d 32 37 2e 33 20 7b 65 78 70  t expr-27.3 {exp
0d60: 72 20 2d 20 4e 61 4e 20 69 73 20 75 6e 6f 72 64  r - NaN is unord
0d70: 65 72 65 64 20 2d 20 6e 6f 74 20 63 6f 6d 70 69  ered - not compi
0d80: 6c 65 64 7d 20 7b 0a 20 20 20 20 73 65 74 20 70  led} {.    set p
0d90: 72 6f 62 6c 65 6d 73 20 7b 7d 0a 20 20 20 20 73  roblems {}.    s
0da0: 65 74 20 6e 61 6d 65 73 20 7b 0a 09 2d 49 6e 66  et names {..-Inf
0db0: 69 6e 69 74 79 20 2d 4e 6f 72 6d 61 6c 20 2d 53  inity -Normal -S
0dc0: 75 62 6e 6f 72 6d 61 6c 20 2d 30 20 2b 30 20 2b  ubnormal -0 +0 +
0dd0: 53 75 62 6e 6f 72 6d 61 6c 20 2b 4e 6f 72 6d 61  Subnormal +Norma
0de0: 6c 20 2b 49 6e 66 69 6e 69 74 79 20 4e 61 4e 0a  l +Infinity NaN.
0df0: 20 20 20 20 7d 0a 20 20 20 20 66 6f 72 65 61 63      }.    foreac
0e00: 68 20 6e 61 6d 65 31 20 24 6e 61 6d 65 73 20 7b  h name1 $names {
0e10: 0a 09 66 6f 72 65 61 63 68 20 6f 70 20 7b 3c 20  ..foreach op {< 
0e20: 3c 3d 20 3d 3d 20 21 3d 20 3e 3d 20 3e 7d 20 7b  <= == != >= >} {
0e30: 0a 09 20 20 20 20 70 75 74 73 20 22 24 69 65 65  ..    puts "$iee
0e40: 65 56 61 6c 75 65 73 28 24 6e 61 6d 65 31 29 20  eValues($name1) 
0e50: 24 6f 70 20 24 69 65 65 65 56 61 6c 75 65 73 28  $op $ieeeValues(
0e60: 4e 61 4e 29 22 0a 09 20 20 20 20 69 66 20 22 5c  NaN)"..    if "\
0e70: 24 69 65 65 65 56 61 6c 75 65 73 28 24 6e 61 6d  $ieeeValues($nam
0e80: 65 31 29 20 24 6f 70 20 5c 24 69 65 65 65 56 61  e1) $op \$ieeeVa
0e90: 6c 75 65 73 28 4e 61 4e 29 22 20 7b 0a 09 09 61  lues(NaN)" {...a
0ea0: 70 70 65 6e 64 20 70 72 6f 62 6c 65 6d 73 20 24  ppend problems $
0eb0: 6e 61 6d 65 31 20 7b 20 7d 20 24 6f 70 20 7b 20  name1 { } $op { 
0ec0: 7d 20 4e 61 4e 20 5c 0a 09 09 20 20 20 20 22 3a  } NaN \...    ":
0ed0: 20 72 65 73 75 6c 74 20 69 73 20 31 2c 20 73 68   result is 1, sh
0ee0: 6f 75 6c 64 20 62 65 20 30 22 20 5c 6e 0a 09 20  ould be 0" \n.. 
0ef0: 20 20 20 7d 0a 09 20 20 20 20 69 66 20 22 5c 24     }..    if "\$
0f00: 69 65 65 65 56 61 6c 75 65 73 28 4e 61 4e 29 20  ieeeValues(NaN) 
0f10: 24 6f 70 20 5c 24 69 65 65 65 56 61 6c 75 65 73  $op \$ieeeValues
0f20: 28 24 6e 61 6d 65 31 29 22 20 7b 0a 09 09 61 70  ($name1)" {...ap
0f30: 70 65 6e 64 20 70 72 6f 62 6c 65 6d 73 20 4e 61  pend problems Na
0f40: 4e 20 7b 20 7d 20 24 6f 70 20 7b 20 7d 20 24 6e  N { } $op { } $n
0f50: 61 6d 65 31 20 5c 0a 09 09 20 20 20 20 22 3a 20  ame1 \...    ": 
0f60: 72 65 73 75 6c 74 20 69 73 20 31 2c 20 73 68 6f  result is 1, sho
0f70: 75 6c 64 20 62 65 20 30 22 20 5c 6e 0a 09 20 20  uld be 0" \n..  
0f80: 20 20 7d 0a 09 7d 0a 20 20 20 20 7d 0a 20 20 20    }..}.    }.   
0f90: 20 73 65 74 20 70 72 6f 62 6c 65 6d 73 0a 7d 20   set problems.} 
0fa0: 7b 7d 0a 0a 74 65 73 74 20 65 78 70 72 2d 32 37  {}..test expr-27
0fb0: 2e 34 20 7b 65 78 70 72 20 2d 20 4e 61 4e 20 69  .4 {expr - NaN i
0fc0: 73 20 75 6e 6f 72 64 65 72 65 64 20 2d 20 63 6f  s unordered - co
0fd0: 6d 70 69 6c 65 64 7d 20 7b 0a 20 20 20 20 73 65  mpiled} {.    se
0fe0: 74 20 70 72 6f 62 6c 65 6d 73 20 7b 7d 0a 20 20  t problems {}.  
0ff0: 20 20 73 65 74 20 6e 61 6d 65 73 20 7b 0a 09 2d    set names {..-
1000: 49 6e 66 69 6e 69 74 79 20 2d 4e 6f 72 6d 61 6c  Infinity -Normal
1010: 20 2d 53 75 62 6e 6f 72 6d 61 6c 20 2d 30 20 2b   -Subnormal -0 +
1020: 30 20 2b 53 75 62 6e 6f 72 6d 61 6c 20 2b 4e 6f  0 +Subnormal +No
1030: 72 6d 61 6c 20 2b 49 6e 66 69 6e 69 74 79 20 4e  rmal +Infinity N
1040: 61 4e 0a 20 20 20 20 7d 0a 20 20 20 20 66 6f 72  aN.    }.    for
1050: 65 61 63 68 20 6e 61 6d 65 31 20 24 6e 61 6d 65  each name1 $name
1060: 73 20 7b 0a 09 66 6f 72 65 61 63 68 20 6f 70 20  s {..foreach op 
1070: 7b 3c 20 3c 3d 20 3d 3d 20 21 3d 20 3e 3d 20 3e  {< <= == != >= >
1080: 7d 20 7b 0a 09 20 20 20 20 70 75 74 73 20 22 24  } {..    puts "$
1090: 69 65 65 65 56 61 6c 75 65 73 28 24 6e 61 6d 65  ieeeValues($name
10a0: 31 29 20 24 6f 70 20 24 69 65 65 65 56 61 6c 75  1) $op $ieeeValu
10b0: 65 73 28 4e 61 4e 29 22 0a 09 20 20 20 20 69 66  es(NaN)"..    if
10c0: 20 7b 20 5b 74 65 73 74 24 6f 70 20 24 69 65 65   { [test$op $iee
10d0: 65 56 61 6c 75 65 73 28 24 6e 61 6d 65 31 29 20  eValues($name1) 
10e0: 24 69 65 65 65 56 61 6c 75 65 73 28 4e 61 4e 29  $ieeeValues(NaN)
10f0: 5d 20 7d 20 7b 0a 09 09 61 70 70 65 6e 64 20 70  ] } {...append p
1100: 72 6f 62 6c 65 6d 73 20 24 6e 61 6d 65 31 20 7b  roblems $name1 {
1110: 20 7d 20 24 6f 70 20 7b 20 7d 20 4e 61 4e 20 5c   } $op { } NaN \
1120: 0a 09 09 20 20 20 20 22 3a 20 72 65 73 75 6c 74  ...    ": result
1130: 20 69 73 20 31 2c 20 73 68 6f 75 6c 64 20 62 65   is 1, should be
1140: 20 30 22 20 5c 6e 0a 09 20 20 20 20 7d 0a 09 20   0" \n..    }.. 
1150: 20 20 20 69 66 20 7b 20 5b 74 65 73 74 24 6f 70     if { [test$op
1160: 20 24 69 65 65 65 56 61 6c 75 65 73 28 4e 61 4e   $ieeeValues(NaN
1170: 29 20 24 69 65 65 65 56 61 6c 75 65 73 28 24 6e  ) $ieeeValues($n
1180: 61 6d 65 31 29 5d 20 7d 20 7b 0a 09 09 61 70 70  ame1)] } {...app
1190: 65 6e 64 20 70 72 6f 62 6c 65 6d 73 20 4e 61 4e  end problems NaN
11a0: 20 7b 20 7d 20 24 6f 70 20 7b 20 7d 20 24 6e 61   { } $op { } $na
11b0: 6d 65 31 20 5c 0a 09 09 20 20 20 20 22 3a 20 72  me1 \...    ": r
11c0: 65 73 75 6c 74 20 69 73 20 31 2c 20 73 68 6f 75  esult is 1, shou
11d0: 6c 64 20 62 65 20 30 22 20 5c 6e 0a 09 20 20 20  ld be 0" \n..   
11e0: 20 7d 0a 09 7d 0a 20 20 20 20 7d 0a 20 20 20 20   }..}.    }.    
11f0: 73 65 74 20 70 72 6f 62 6c 65 6d 73 0a 7d 20 7b  set problems.} {
1200: 7d 0a                                            }.