aboutsummaryrefslogtreecommitdiff
path: root/src/testsuite/interpreter/testSyntax.spad
blob: 9cd16c217d3078c05313ded77ceadd505d62a7e0 (plain)
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
++ Contibuted by Yixin Cao
)abbrev domain TD TestDomain
import OutputPackage
TestDomain :Public == Private where
  Public == with
    testCase: Syntax -> Boolean
    testCoerceTo: Symbol -> Syntax
    testCoerceFrom: Syntax -> Symbol
    testBuildSyntax: () -> Syntax
    testGetOperator: Syntax -> Syntax
    testGetOperator: () -> Syntax
    test: Syntax -> Boolean
    test: () -> Boolean

  Private == add
    testBuildSyntax ==
      b:=("b")::Symbol
      a:=("a")::Symbol
      m:=("-")::Symbol
      c:=buildSyntax('_*, [a::Syntax, 3::Syntax])
      d:=buildSyntax(m::Syntax, [b::Syntax, c])
      d:=buildSyntax('_-, [3::Syntax, 2::Syntax])
      d

    testCase(x) ==
      x case Symbol

    testCoerceFrom x ==
      x case Symbol => coerce(x)@Symbol

    testCoerceTo s ==
      error "not implemented yet"

    testGetOperator  ==
      (getOperator testBuildSyntax())::Syntax    

    test ==
      test testBuildSyntax()

    test x ==
      output "testing case function"
      testCase x
      output "case function works"

      output "testing coerce from Syntax to Symbol"
      testCoerceFrom x
      output "coerce (from) function works"

      output "testing getOperator function"
      testGetOperator()
      output "getOperator function works"

      true