Debian Codegraph @

lang/interpret_test/TestAstFunc2/deploy-readfile2.txtar

raw
1 -- metadata.yaml --
2 #files: "files/" # these are some extra files we can use (is the default)
3 -- main.mcl --
4 import "golang/strings"
5 import "deploy"
6 import "second.mcl"
7
8 #$f1 = "/metadata.yaml" # works
9 #$f1 = "/main.mcl" # works
10 $f1 = "/files/file1"
11
12 $f2 = "/files/file2"
13
14 # the abspath method shouldn't be used often, it's here for testing...
15 if $f1 != deploy.abspath($f1) { # should be the same, since we're in the same dir
16 test "f1 error" {}
17 }
18 if $f2 != $second.f2 {
19 test "f2 error" {}
20 }
21
22 # the readfileabs method shouldn't be used often, it's here for testing...
23 $x1 = deploy.readfileabs($f1)
24 $x2 = deploy.readfileabs($f2)
25
26 if $x1 != deploy.readfile($f1) {
27 test "x1 error" {}
28 }
29 if $x2 != $second.x2 {
30 test "x2 error" {}
31 }
32
33 # hide the newlines from our output
34 test [strings.trim_space($x1),] {}
35 test [strings.trim_space($x2),] {}
36 -- second.mcl --
37 import "deploy"
38
39 # relative paths for us
40 $f = "/files/file2" # real file is here as well
41 $f2 = deploy.abspath($f)
42 $x2 = deploy.readfile($f)
43 -- files/file1 --
44 This is file1 in the files/ folder.
45 -- files/file2 --
46 This is file2 in the files/ folder.
47 -- OUTPUT --
48 Vertex: test[This is file1 in the files/ folder.]
49 Vertex: test[This is file2 in the files/ folder.]