Debian Codegraph @

lang/interpret_test/TestAstFunc2/deploy-readfile0.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 import "mod1/"
8
9 #$f1 = "/metadata.yaml" # works
10 #$f1 = "/main.mcl" # works
11 $f1 = "/files/file1"
12
13 $f2 = "/files/file2"
14
15 $f3 = "/mod1/files/file3"
16
17 # the abspath method shouldn't be used often, it's here for testing...
18 if $f1 != deploy.abspath($f1) { # should be the same, since we're in the same dir
19 test "f1 error" {}
20 }
21 if $f2 != $second.f2 {
22 test "f2 error" {}
23 }
24 if $f3 != $mod1.f3 {
25 test "f3 error" {}
26 }
27
28 # the readfileabs method shouldn't be used often, it's here for testing...
29 $x1 = deploy.readfileabs($f1)
30 $x2 = deploy.readfileabs($f2)
31 $x3 = deploy.readfileabs($f3)
32
33 if $x1 != deploy.readfile($f1) {
34 test "x1 error" {}
35 }
36 if $x2 != $second.x2 {
37 test "x2 error" {}
38 }
39 if $x3 != $mod1.x3 {
40 test "x3 error" {}
41 }
42
43 # hide the newlines from our output
44 test [strings.trim_space($x1),] {}
45 test [strings.trim_space($x2),] {}
46 test [strings.trim_space($x3),] {}
47 # debugging:
48 #test "f1" {
49 # anotherstr => $x1,
50 #}
51 #test "f2" {
52 # anotherstr => $x2,
53 #}
54 #test "f3" {
55 # anotherstr => $x3,
56 #}
57 -- second.mcl --
58 import "deploy"
59
60 # relative paths for us
61 $f = "/files/file2" # real file is here as well
62 $f2 = deploy.abspath($f)
63 $x2 = deploy.readfile($f)
64 -- files/file1 --
65 This is file1 in the files/ folder.
66 -- files/file2 --
67 This is file2 in the files/ folder.
68 -- mod1/metadata.yaml --
69 #files: "files/" # these are some extra files we can use (is the default)
70 -- mod1/main.mcl --
71 import "deploy"
72
73 # relative paths for us
74 $f = "/files/file3" # real file is in: /mod1/files/file3
75 $f3 = deploy.abspath($f)
76 $x3 = deploy.readfile($f)
77 -- mod1/files/file3 --
78 This is file3 in the files/ folder inside of the mod1/ module.
79 -- OUTPUT --
80 Vertex: test[This is file1 in the files/ folder.]
81 Vertex: test[This is file2 in the files/ folder.]
82 Vertex: test[This is file3 in the files/ folder inside of the mod1/ module.]