@@ -25,29 +25,39 @@ import file("../meta/path-utils.arr") as P
2525import filesystem as FS
2626
2727check-well-formed = _check-well-formed
28+ fmt-well-formed = _fmt-well-formed
2829
2930# TODO: test for file not existing
3031
31- check "well-formed: unparsable" :
32- path = P . file( "unparsable.arr" )
33-
34- # FIXME: how to make this relative to current file
35- check-well-formed( path)
36- is
37- some( cannot-parse(
38- {
39- exn: ERR . parse-error-eof(
40- S . srcloc( path, 3 , 1 , 13 , 3 , 1 , 13 )) ,
41- message: "There were 0 potential parses.\n" +
42- "Parse failed, next token is <end of file> at " + path + ", 3:1-3:1"
43- } ,
44- FS . read-file-string( path)
45- ))
32+ check "well-formed: path-doesnt-exist" :
33+ path = P . file( "this/file-doesnt/exist/i/hope.arr" )
34+ check-well-formed( path) is some( path-doesnt-exist( path))
35+ end
36+
37+ check "well-formed: path-isnt-file" :
38+ check-well-formed( P . file( "dir" )) is some( path-isnt-file( P . file( "dir" )))
39+ end
40+
41+ expected-unparsable =
42+ let path = P . file( "unparsable.arr" ) :
43+ cannot-parse(
44+ {
45+ exn: ERR . parse-error-eof(
46+ S . srcloc( path, 3 , 1 , 13 , 3 , 1 , 13 )) ,
47+ message: "There were 0 potential parses.\n" +
48+ "Parse failed, next token is <end of file> at " + path + ", 3:1-3:1"
49+ } ,
50+ FS . read-file-string( path)
51+ )
52+ end
53+
54+ check "well-formed: cannot-parse" :
55+ check-well-formed( P . file( "unparsable.arr" )) is some( expected-unparsable)
4656end
4757
4858check "well-formed: wf" :
49- check-well-formed( P . file( "not-wf.arr" ))
50- satisfies
59+ res = check-well-formed( P . file( "not-wf.arr" ))
60+ res satisfies
5161 { ( x) : cases ( Option ) x:
5262 | some( shadow x) =>
5363 cases ( WFBlock ) x:
@@ -56,4 +66,14 @@ check "well-formed: wf":
5666 | else => false
5767 end
5868 | else => false end }
69+ print( to-repr( fmt-well-formed( res. value)) + "\n" )
70+ end
71+
72+ check "fmt-well-formed: smoke" :
73+ fmt-well-formed( path-doesnt-exist(
74+ P . file( "this/file-doesnt/exist/i/hope.arr" ))) does-not-raise
75+ fmt-well-formed( path-doesnt-exist(
76+ P . file( "this-file-doesnt-exist-i-hope.arr" ))) does-not-raise
77+ fmt-well-formed( path-isnt-file( P . file( "dir" ))) does-not-raise
78+ fmt-well-formed( expected-unparsable) does-not-raise
5979end
0 commit comments