Browse code
Run test cases from the specification
Fernando Borretti authored on 22/04/2015 22:30:15
Showing 24 changed files
Showing 24 changed files
- t/data/collections/map-seq.json
- t/data/collections/map-seq.yaml
- t/data/collections/scalar-map.json
- t/data/collections/scalar-map.yaml
- t/data/collections/scalar-seq-map.json
- t/data/collections/scalar-seq-map.yaml
- t/data/collections/scalar-seq.json
- t/data/collections/scalar-seq.yaml
- t/data/collections/seq-seq.json
- t/data/collections/seq-seq.yaml
- t/data/scalars/example.json
- t/data/scalars/folded.json
- t/data/scalars/folded.yaml
- t/data/scalars/indent.json
- t/data/scalars/indent.yaml
- t/data/scalars/long-folded.json
- t/data/scalars/long-folded.yaml
- t/data/scalars/multi-line.json
- t/data/scalars/multi-line.yaml
- t/data/scalars/newlines.json
- t/data/scalars/newlines.yaml
- t/data/scalars/quoted.json
- t/data/scalars/quoted.yaml
- t/spec.lisp
0 | 4 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,41 @@ |
1 |
+{ |
|
2 |
+ "product": [ |
|
3 |
+ { |
|
4 |
+ "sku": "BL394D", |
|
5 |
+ "price": 450.0, |
|
6 |
+ "description": "Basketball", |
|
7 |
+ "quantity": 4 |
|
8 |
+ }, |
|
9 |
+ { |
|
10 |
+ "sku": "BL4438H", |
|
11 |
+ "price": 2392.0, |
|
12 |
+ "description": "Super Hoop", |
|
13 |
+ "quantity": 1 |
|
14 |
+ } |
|
15 |
+ ], |
|
16 |
+ "ship-to": { |
|
17 |
+ "given": "Chris", |
|
18 |
+ "family": "Dumars", |
|
19 |
+ "address": { |
|
20 |
+ "city": "Royal Oak", |
|
21 |
+ "state": "MI", |
|
22 |
+ "postal": 48046, |
|
23 |
+ "lines": "458 Walkman Dr.\nSuite #292\n" |
|
24 |
+ } |
|
25 |
+ }, |
|
26 |
+ "tax": 251.41999999999999, |
|
27 |
+ "comments": "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.", |
|
28 |
+ "bill-to": { |
|
29 |
+ "given": "Chris", |
|
30 |
+ "family": "Dumars", |
|
31 |
+ "address": { |
|
32 |
+ "city": "Royal Oak", |
|
33 |
+ "state": "MI", |
|
34 |
+ "postal": 48046, |
|
35 |
+ "lines": "458 Walkman Dr.\nSuite #292\n" |
|
36 |
+ } |
|
37 |
+ }, |
|
38 |
+ "invoice": 34843, |
|
39 |
+ "date": "2001-01-23", |
|
40 |
+ "total": 4443.5200000000004 |
|
41 |
+} |
0 | 8 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,27 @@ |
1 |
+(in-package :cl-user) |
|
2 |
+(defpackage cl-yaml-test.spec |
|
3 |
+ (:use :cl :fiveam) |
|
4 |
+ (:export :spec)) |
|
5 |
+(in-package :cl-yaml-test.spec) |
|
6 |
+ |
|
7 |
+(def-suite spec |
|
8 |
+ :description "Test cases from the spec.") |
|
9 |
+(in-suite spec) |
|
10 |
+ |
|
11 |
+(defun parse-corresponding-file (yaml-file) |
|
12 |
+ (let ((json-file (make-pathname :defaults yaml-file |
|
13 |
+ :type "json"))) |
|
14 |
+ (yason:parse json-file))) |
|
15 |
+ |
|
16 |
+(test spec-tests |
|
17 |
+ (let ((directories (fad:list-directory |
|
18 |
+ (asdf:system-relative-pathname :cl-yaml-test |
|
19 |
+ #p"t/data/")))) |
|
20 |
+ (loop for directory in directories do |
|
21 |
+ (loop for file in (uiop:directory-files directory) do |
|
22 |
+ (when (string= (pathname-type file) "yaml") |
|
23 |
+ (format t "~%Spec: ~A" (pathname-name file)) |
|
24 |
+ (let ((data (yaml:parse file)) |
|
25 |
+ (json-data (parse-corresponding-file file))) |
|
26 |
+ (is-true |
|
27 |
+ (generic-comparability:equals data json-data)))))))) |