A => test/other/.found +0 -0
A => test/other/curated/.found +0 -0
A => test/out/.found +0 -0
A => test/spec/.found +0 -0
M test/test-all.sml +2 -2
@@ 31,7 31,7 @@ fun runTestSuite (suiteName, tests) =
else OS.Process.success
end
-val allTests = [
+fun ttl_tests () = [
(TestPrefix.name, TestPrefix.tests ()),
(TestProperty.name, TestProperty.tests ()),
(TestIndex.name, TestIndex.tests ()),
@@ 61,7 61,7 @@ fun handleArgs args =
else code
end)
OS.Process.success
- allTests
+ (ttl_tests ())
| _ => usage ()
fun main () =
M test/test-collection.sml +2 -0
@@ 9,6 9,8 @@ structure TestCollection :> TESTS = stru
open RdfNode
open RdfStandardIRIs
+ type test = string * (unit -> bool)
+
val name = "collection"
(* Renumber blank nodes, starting from 1 each time this is called *)
M test/test-curated.sml +7 -9
@@ 1,13 1,11 @@
structure TestCurated : TESTS = struct
- open TestSupport
-
- val name = "curated"
+ open TestSupport TestDir
- val testFileDir = "test/other"
- val referenceDir = "test/other/curated"
- val outFileDir = "test/out"
+ type test = string * (unit -> bool)
+
+ val name = "curated"
fun convertFile (infile, outfile) =
let val instream = TextIO.openIn infile
@@ 56,9 54,9 @@ structure TestCurated : TESTS = struct
fun tests () =
map (fn f =>
(f, fn () => checkConversion
- (testFileDir ^ "/" ^ f ^ ".ttl")
- (outFileDir ^ "/" ^ f ^ ".ttl")
- (referenceDir ^ "/" ^ f ^ ".ttl")))
+ (testFileDir "other" ^ "/" ^ f ^ ".ttl")
+ (testFileDir "out" ^ "/" ^ f ^ ".ttl")
+ (testFileDir "other/curated" ^ "/" ^ f ^ ".ttl")))
[ "bnode-nested-2", "bnode-nested", "bnode", "boolean",
"collections", "example1", "example2", "example3", "goblin",
"iris", "numbers", "quoted", "quoted2" ]
A => test/test-dir.sml +25 -0
@@ 0,0 1,25 @@
+
+structure TestDir = struct
+
+ fun testFileDir name =
+ let val dir = "test/" ^ name
+ val candidateDirectories = ["sml-ttl", "."]
+ val checkFile = ".found"
+ in
+ case foldl (fn (candidate, SOME acceptable) => SOME acceptable
+ | (candidate, NONE) =>
+ if OS.FileSys.access (candidate ^ "/" ^ dir ^ "/" ^ checkFile,
+ [OS.FileSys.A_READ])
+ then SOME candidate
+ else NONE)
+ NONE
+ candidateDirectories of
+ NONE => raise Fail
+ ("Test file directory " ^ dir ^
+ " not found (candidate parent dirs: "
+ ^ String.concatWith ", " candidateDirectories
+ ^ ")")
+ | SOME acceptable => acceptable ^ "/" ^ dir
+ end
+
+end
M test/test-index.sml +7 -0
@@ 12,6 12,13 @@ functor TestIndexFn (Arg : TEST_INDEX_AR
structure IX = Arg.IX
structure P = IndexPickerFn(IX)
+ fun checkSets converter greater (a, b) =
+ checkLists converter
+ (ListMergeSort.sort greater a,
+ ListMergeSort.sort greater b)
+
+ type test = string * (unit -> bool)
+
val name = "index"
fun iri i = RdfNode.IRI (Iri.fromString i)
M test/test-prefix.sml +2 -0
@@ 3,6 3,8 @@ functor TestPrefixFn (P: PREFIX_TABLE) :
open TestSupport
+ type test = string * (unit -> bool)
+
val name = "prefix"
fun makeTable pairs =
M test/test-property.sml +6 -3
@@ 1,12 1,14 @@
functor TestPropertyFn (P: STORE_PROPERTY) :> TESTS = struct
- open TestSupport
- open RdfNode
+ open TestSupport RdfNode TestDir
+ type test = string * (unit -> bool)
+
val name = "property";
- val testfile = "test/other/goblin.ttl"
+ fun testFile () = testFileDir "other" ^ "/goblin.ttl"
+
val goblinIri = Iri.fromString "http://example.org/#green-goblin"
val spiderIri = Iri.fromString "http://example.org/#spiderman"
val goblinNode = IRI goblinIri
@@ 17,6 19,7 @@ functor TestPropertyFn (P: STORE_PROPERT
fun loadTestfile () =
let open StoreFileLoader
+ val testfile = testFile ()
in
case loadFileAsNewStore (NONE, testfile) of
FORMAT_NOT_SUPPORTED =>
M test/test-store.sml +7 -0
@@ 16,6 16,13 @@ functor TestStoreFn (Arg : TEST_STORE_AR
structure S = Arg.S
+ fun checkSets converter greater (a, b) =
+ checkLists converter
+ (ListMergeSort.sort greater a,
+ ListMergeSort.sort greater b)
+
+ type test = string * (unit -> bool)
+
val name = "store"
fun iri i = RdfNode.IRI (Iri.fromString i)
M test/test-support.sml +0 -8
@@ 1,9 1,6 @@
structure TestSupport = struct
- type test = string * (unit -> bool)
- type testSuite = string * test list
-
fun report converter (obtained, expected) =
print ("--- Expected " ^ (converter expected)
^ "\n--- Obtained " ^ (converter obtained) ^ "\n")
@@ 35,10 32,5 @@ structure TestSupport = struct
else
checkLists' (a, b)
end
-
- fun checkSets converter greater (a, b) =
- checkLists converter
- (ListMergeSort.sort greater a,
- ListMergeSort.sort greater b)
end
M test/test-turtle-parser.sml +6 -6
@@ 1,8 1,10 @@
functor TestTurtleParserFn (P: RDF_PARSER) :> TESTS = struct
- open TestSupport RdfTriple Prefix
+ open TestSupport RdfTriple Prefix TestDir
+ type test = string * (unit -> bool)
+
val name = "turtle-parser"
fun checkTriples str (P.PARSE_ERROR err) =
@@ 48,11 50,9 @@ functor TestTurtleParserFn (P: RDF_PARSE
result
end
- val testFileDir = "test/other"
-
- val goodFileTests =
+ fun goodFileTests () =
map (fn f =>
- (f, fn () => goodFile (testFileDir ^ "/" ^ f ^ ".ttl")))
+ (f, fn () => goodFile (testFileDir "other" ^ "/" ^ f ^ ".ttl")))
[ "bnode-nested-2", "bnode-nested", "bnode", "boolean",
"collections", "example1", "example2", "example3", "goblin",
"iris", "numbers", "quoted", "quoted2" ]
@@ 140,7 140,7 @@ functor TestTurtleParserFn (P: RDF_PARSE
prefixes = [ ( "", Iri.empty ) ],
triples = [ iriTriple ("%", "a#c", "ab(") ] }
)
- ] @ goodFileTests
+ ] @ (goodFileTests ())
end
M test/test-turtle-spec.sml +5 -6
@@ 1,18 1,17 @@
functor TestTurtleSpecFn (P: RDF_PARSER) :> TESTS = struct
- open TestSupport RdfNode RdfTriple Prefix
+ open TestSupport RdfNode RdfTriple Prefix TestDir
+ type test = string * (unit -> bool)
+
val name = "turtle-spec"
structure L = TurtleLoader (* for manifest in ttl format *)
structure S = Store
- val testFileDir = "test/spec"
- val outFileDir = "test/out"
-
- fun testFile filename = testFileDir ^ "/" ^ filename
- fun tempFile filename = outFileDir ^ "/" ^ filename
+ fun testFile filename = testFileDir "spec" ^ "/" ^ filename
+ fun tempFile filename = testFileDir "out" ^ "/" ^ filename
val baseIri = "http://example/base/"
M test/tests.mlb +1 -0
@@ 1,6 1,7 @@
../src/sml-ttl.mlb
tests.sig
test-support.sml
+test-dir.sml
test-prefix.sml
test-property.sml
test-index.sml