-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.scm
More file actions
47 lines (41 loc) · 1.35 KB
/
tests.scm
File metadata and controls
47 lines (41 loc) · 1.35 KB
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
(require-library simple-tests)
(import simple-tests)
(import (srfi 1))
(import (net graphql read))
(import (net graphql write))
(define (deb s x)
(display "deb: ") (display s) (display " ") (write x) (newline) x)
(define (lines . lines_)
(fold (lambda (line so-far) (string-append so-far line "\n"))
"" lines_))
(define-test (hello-world)
(equal? (graphql->string '(query query-name field-1 field-2))
(lines
"{"
" query_name {"
" field_1"
" field_2"
" }"
"}")))
(define-test (read-simple)
(equal? (string->graphql "{ abc def ghi }")
'((query #f abc def ghi)))
(equal? (string->graphql "query { abc def ghi }")
'((query #f abc def ghi)))
(equal? (string->graphql "query foo { abc def ghi }")
'((query foo abc def ghi)))
(equal? (string->graphql
"query foo @deprecated(reason: $foo) { abc { a b c } def ghi }")
'((query (foo (@ deprecated (reason ($ foo))))
(field abc a b c)
def
ghi)))
(equal? (string->graphql
"query foo @deprecated(reason: 123) { abc { a b c } def ghi }")
'((query (foo (@ deprecated (reason 123)))
(field abc a b c)
def
ghi))))
(compound-test (simple-tests)
(hello-world)
(read-simple))