aboutsummaryrefslogtreecommitdiffstats
path: root/csc/compare-test.csc
blob: b7101154019f90585b5fdb4c54f13fac31a21795 (plain) (blame)
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
(define-library (csc compare-test)
  (import (scheme base)
          (only (csc match)
            define-match-record-type)
          (only (csc testing)
            assert
            test)
          (csc compare))
  (begin


    (test diff-list
      (assert
        (string=?
          "   (
     1
  -  2
     3
  +  3.5
     4
   )
"
          (diff '(1 2 3 4) '(1 3 3.5 4)))))


    (define-match-record-type <test-type>
      (make-test-type a b)
      test-type?
      %test-type
      (a test-type-a)
      (b test-type-b))


    (test diff-record
      (assert
        (string=?
          "   (
     (!type .
       <test-type>
     )
     (a .
       5
     )
     (b .
    -  5
    +  6
     )
   )
"
          (diff (make-test-type 5 5) (make-test-type 5 6) (cons test-type? %test-type)))))


    (test diff-multiline-string
      (assert
        (string=?
          "   (
     (!type .
       string
     )
     (value .
       (
         line-one
      -  line-two
         line-three
       )
     )
   )
"
          (diff "line-one\nline-two\nline-three" "line-one\nline-three"))))


    (test diff-vector
      (assert
        (string=?
      "   (
     (!type .
       vector
     )
     (value .
       (
         1
      -  2
         3
       )
     )
   )
"
          (diff #(1 2 3) #(1 3)))))


    (test diff-symbol-list
      (assert
        (string=?
          "-  symbol
+  (
+  )
"
          (diff 'symbol '()))))))