File: DocumentTests.sml

package info (click to toggle)
smlsharp 4.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 123,732 kB
  • sloc: ansic: 16,725; sh: 4,347; makefile: 2,191; java: 742; haskell: 493; ruby: 305; cpp: 284; pascal: 256; ml: 255; lisp: 141; asm: 97; sql: 74
file content (158 lines) | stat: -rw-r--r-- 4,849 bytes parent folder | download | duplicates (2)
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
(**
 * document based test
 *
 * @copyright (C) 2021 SML# Development Team.
 *)

structure DocumentTests =
struct
open SMLUnit.Test SMLUnit.Assert Compiler
structure N = NameEvalError
structure M = MatchError
structure T = TypeInferenceError
structure C = ConstantError

  fun testExec name srcfile objfiles =
      let
        val srcfilePath = "document/" ^ srcfile
        val objfilePaths = map (fn file => "document/" ^ file) objfiles
        fun exec () = execute (link srcfilePath (compile objfilePaths))
      in
        Test (name, exec)
      end

  fun testExecError name srcfile objfiles errorFn =
      let
        val srcfilePath = "document/" ^ srcfile
        val objfilePaths = map (fn file => "document/" ^ file) objfiles
        fun exec () = (execute (link srcfilePath (compile objfilePaths));
                       fail "must cause a compile error")
      in
        Test (name, fn () => errorFn exec)
      end
  
  val tests = TestList [
    (* interface file test *)
    testExec
      "ProvideVal" 
      "ProvideValMain.smi" 
      ["ProvideVal.sml", "ProvideValMain.sml"],
    testExec
      "ProvideType" 
      "ProvideTypeMain.smi" 
      ["ProvideType.sml", "ProvideTypeMain.sml"],
    testExec
      "ProvideTypeRepAtomic" 
      "ProvideTypeRepAtomicMain.smi" 
      ["ProvideTypeRepAtomic.sml", "ProvideTypeRepAtomicMain.sml"],
    testExec
      "ProvideTypeRepContag" 
      "ProvideTypeRepContagMain.smi" 
      ["ProvideTypeRepContag.sml", "ProvideTypeRepContagMain.sml"],
    testExec
      "ProvideTypeRepBoxed" 
      "ProvideTypeRepBoxedMain.smi" 
      ["ProvideTypeRepBoxed.sml", "ProvideTypeRepBoxedMain.sml"],
    testExec
      "ProvideDatatype" 
      "ProvideDatatypeMain.smi" 
      ["ProvideDatatype.sml", "ProvideDatatypeMain.sml"],
    testExec
      "ProvideException" 
      "ProvideExceptionMain.smi" 
      ["ProvideException.sml", "ProvideExceptionMain.sml"],
    testExec
      "ProvideStr" 
      "ProvideStrMain.smi" 
      ["ProvideStr.sml", "ProvideStrMain.sml"],
    testExec
      "Require" 
      "RequireMain.smi" 
      ["Require.sml", "RequireMain.sml"],
    testExec
      "RequireSigFileMain" 
      "RequireSigFileMain.smi" 
      ["RequireSigFile.sml", "RequireSigFileMain.sml"],
    testExec
      "Interface" 
      "InterfaceMain.smi" 
      ["Interface.sml", "InterfaceMain.sml"],
    testExec
      "ReplicationDecl" 
      "ReplicationDeclMain.smi" 
      ["ReplicationDecl1.sml",
       "ReplicationDecl2.sml",
       "ReplicationDeclMain.sml"],
    testExec
      "ReplicationDatatypeDecl" 
      "ReplicationDatatypeDeclMain.smi" 
      ["ReplicationDatatypeDecl1.sml",
       "ReplicationDatatypeDecl2.sml",
       "ReplicationDatatypeDeclMain.sml"],

    testExecError 
      "RequireLocal" 
      "RequireLocalMain.smi" 
      ["RequireLocal.sml", "RequireLocalMain.sml"]
      (fn exec => exec ()
          handle CompileError (s, [(_, _, N.ProvideUndefinedID _)]) => ()),

(* これは dummy typpe warning で正しい?
    (* expression test *)
    testExec
      "ExpressionFieldSelectorDummyType" 
      "ExpressionFieldSelectorDummyType.smi" 
      ["ExpressionFieldSelectorDummyType.sml"],
*)

    testExec
      "LiteralMultibyteChar" 
      "LiteralMultibyteChar.smi" 
      ["LiteralMultibyteChar.sml"],
    testExec
      "FunDeclRecTyped" 
      "FunDeclRecTyped.smi" 
      ["FunDeclRecTyped.sml"],

    testExecError
      "CaseOfZeroAndMinusZero" 
      "CaseOfZeroAndMinusZero.smi" 
      ["CaseOfZeroAndMinusZero.sml"]
      (fn exec => exec ()
          handle CompileError (s, [(_, _, M.MatchError _)]) => ()),
    testExecError
      "CaseOfDecAndHexInt" 
      "CaseOfDecAndHexInt.smi" 
      ["CaseOfDecAndHexInt.sml"]
      (fn exec => exec ()
          handle CompileError (s, [(_, _, M.MatchError _)]) => ()),
    testExecError
      "CaseOfDecAndHexWord" 
      "CaseOfDecAndHexWord.smi" 
      ["CaseOfDecAndHexWord.sml"]
      (fn exec => exec ()
          handle CompileError (s, [(_, _, M.MatchError _)]) => ()),
(* 確かにおかしいが、一度エラーが起こった後のエラーは、不正確でありうるので、
   当面対処せず。
    testExecError
      "TypeErrorOutput" 
      "TypeErrorOutput.smi" 
      ["TypeErrorOutput.sml"]
      (fn exec => exec ()
          handle CompileError (s, [(_, _, T.TypeAnnotationNotAgree _)]) => ()),
*)
    testExecError
      "FunDeclDatatypePattern" 
      "FunDeclDatatypePattern.smi" 
      ["FunDeclDatatypePattern.sml"]
      (fn exec => exec ()
          handle CompileError (s, [(_, _, T.TypeAnnotationNotAgree _)]) => ()),
    testExecError
      "LiteralLargeConstantError" 
      "LiteralLargeConstantError.smi" 
      ["LiteralLargeConstantError.sml"]
      (fn exec => exec ()
          handle CompileError (s, [(_, _, C.TooLargeConstant)]) => ())
  ]

end