git.fiddlerwoaroof.com
Browse code

Test float support

Fernando Borretti authored on 31/01/2015 00:43:31
Showing 2 changed files
... ...
@@ -6,5 +6,6 @@
6 6
   :components ((:module "t"
7 7
                 :serial t
8 8
                 :components
9
-                ((:file "parser")
9
+                ((:file "float")
10
+                 (:file "parser")
10 11
                  (:file "cl-yaml")))))
11 12
new file mode 100644
... ...
@@ -0,0 +1,30 @@
1
+(in-package :cl-user)
2
+(defpackage cl-yaml-test.float
3
+  (:use :cl :fiveam)
4
+  (:export :float))
5
+(in-package :cl-yaml-test.float)
6
+
7
+(def-suite float
8
+  :description "YAML IEEE float tests.")
9
+(in-suite float)
10
+
11
+(test not-a-number
12
+  (is
13
+   (equal (yaml.float:not-a-number)
14
+          :NaN))
15
+  (is
16
+   (equal (yaml.float:positive-infinity)
17
+          :+Inf))
18
+  (is
19
+   (equal (yaml.float:negative-infinity)
20
+          :-Inf)))
21
+
22
+#+sbcl
23
+(test sbcl-nan
24
+  (let ((yaml.float:*float-strategy* :best-effort))
25
+    (is-true
26
+     (sb-ext:float-nan-p (yaml.float:not-a-number)))
27
+    (is-true
28
+     (sb-ext:float-infinity-p (yaml.float:positive-infinity)))
29
+    (is-true
30
+     (sb-ext:float-infinity-p (yaml.float:negative-infinity)))))