lang: Add a bunch of new language tests

These test both graph shape consistency and single value outputs.
Eventually we want to make the graph shape tests more precise, and also
verify specific outputs how it used to be. For now, this is okay.

Co-authored-by: Samuel Gélineau <gelisam@gmail.com>
This commit is contained in:
James Shubin
2023-09-25 16:16:33 -04:00
parent d4b1e8f1be
commit 8d63b98212
74 changed files with 1001 additions and 686 deletions

View File

@@ -21,41 +21,15 @@ $out2 = $fn2()
test $out1 {}
test $out2 {}
-- OUTPUT --
Edge: bool(false) -> call:funcgen(bool(false)) # b
Edge: bool(false) -> var(b) # var:b
Edge: bool(true) -> call:funcgen(bool(true)) # b
Edge: bool(true) -> var(b) # var:b
Edge: call:fn1() -> var(out1) # var:out1
Edge: call:fn2() -> var(out2) # var:out2
Edge: call:funcgen(bool(false)) -> call:fn2() # call:fn2
Edge: call:funcgen(bool(true)) -> call:fn1() # call:fn1
Edge: func() { str("hello") } -> if( var(b) ) { func() { str("hello") } } else { func() { str("world") } } # a
Edge: func() { str("hello") } -> if( var(b) ) { func() { str("hello") } } else { func() { str("world") } } # a
Edge: func() { str("world") } -> if( var(b) ) { func() { str("hello") } } else { func() { str("world") } } # b
Edge: func() { str("world") } -> if( var(b) ) { func() { str("hello") } } else { func() { str("world") } } # b
Edge: func(b) { if( var(b) ) { func() { str("hello") } } else { func() { str("world") } } } -> call:funcgen(bool(false)) # call:funcgen
Edge: func(b) { if( var(b) ) { func() { str("hello") } } else { func() { str("world") } } } -> call:funcgen(bool(true)) # call:funcgen
Edge: if( var(b) ) { func() { str("hello") } } else { func() { str("world") } } -> func(b) { if( var(b) ) { func() { str("hello") } } else { func() { str("world") } } } # body
Edge: if( var(b) ) { func() { str("hello") } } else { func() { str("world") } } -> func(b) { if( var(b) ) { func() { str("hello") } } else { func() { str("world") } } } # body
Edge: str("hello") -> func() { str("hello") } # body
Edge: str("world") -> func() { str("world") } # body
Edge: var(b) -> if( var(b) ) { func() { str("hello") } } else { func() { str("world") } } # c
Edge: var(b) -> if( var(b) ) { func() { str("hello") } } else { func() { str("world") } } # c
Vertex: bool(false)
Vertex: bool(true)
Vertex: call:fn1()
Vertex: call:fn2()
Vertex: call:funcgen(bool(false))
Vertex: call:funcgen(bool(true))
Vertex: func() { str("hello") }
Vertex: func() { str("world") }
Vertex: func(b) { if( var(b) ) { func() { str("hello") } } else { func() { str("world") } } }
Vertex: func(b) { if( var(b) ) { func() { str("hello") } } else { func() { str("world") } } }
Vertex: if( var(b) ) { func() { str("hello") } } else { func() { str("world") } }
Vertex: if( var(b) ) { func() { str("hello") } } else { func() { str("world") } }
Vertex: str("hello")
Vertex: str("world")
Vertex: var(b)
Vertex: var(b)
Vertex: var(out1)
Vertex: var(out2)
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: call -> call # fn
Edge: call -> call # fn
Vertex: FuncValue
Vertex: FuncValue
Vertex: call
Vertex: call
Vertex: call
Vertex: call
Vertex: const
Vertex: const

View File

@@ -6,20 +6,19 @@ class c1($b) {
test fmt.printf("len is: %d", len($b)) {} # len is 4
}
-- OUTPUT --
Edge: call:len(var(b)) -> call:fmt.printf(str("len is: %d"), call:len(var(b))) # a
Edge: int(-37) -> list(int(13), int(42), int(0), int(-37)) # 3
Edge: int(0) -> list(int(13), int(42), int(0), int(-37)) # 2
Edge: int(13) -> list(int(13), int(42), int(0), int(-37)) # 0
Edge: int(42) -> list(int(13), int(42), int(0), int(-37)) # 1
Edge: list(int(13), int(42), int(0), int(-37)) -> var(b) # var:b
Edge: str("len is: %d") -> call:fmt.printf(str("len is: %d"), call:len(var(b))) # format
Edge: var(b) -> call:len(var(b)) # 0
Vertex: call:fmt.printf(str("len is: %d"), call:len(var(b)))
Vertex: call:len(var(b))
Vertex: int(-37)
Vertex: int(0)
Vertex: int(13)
Vertex: int(42)
Vertex: list(int(13), int(42), int(0), int(-37))
Vertex: str("len is: %d")
Vertex: var(b)
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: const -> composite # 0
Edge: const -> composite # 1
Edge: const -> composite # 2
Edge: const -> composite # 3
Vertex: FuncValue
Vertex: FuncValue
Vertex: call
Vertex: call
Vertex: composite
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const

View File

@@ -15,72 +15,51 @@ include foo(1)
include foo(2)
include foo(3)
-- OUTPUT --
Edge: call:_operator(str("+"), call:_operator(str("+"), var(some_value1), var(some_value2)), int(4)) -> var(inside) # var:inside
Edge: call:_operator(str("+"), call:_operator(str("+"), var(some_value1), var(some_value2)), int(4)) -> var(inside) # var:inside
Edge: call:_operator(str("+"), call:_operator(str("+"), var(some_value1), var(some_value2)), int(4)) -> var(inside) # var:inside
Edge: call:_operator(str("+"), var(some_value1), var(some_value2)) -> call:_operator(str("+"), call:_operator(str("+"), var(some_value1), var(some_value2)), int(4)) # a
Edge: call:_operator(str("+"), var(some_value1), var(some_value2)) -> call:_operator(str("+"), call:_operator(str("+"), var(some_value1), var(some_value2)), int(4)) # a
Edge: call:_operator(str("+"), var(some_value1), var(some_value2)) -> call:_operator(str("+"), call:_operator(str("+"), var(some_value1), var(some_value2)), int(4)) # a
Edge: int(1) -> var(num) # var:num
Edge: int(13) -> var(some_value2) # var:some_value2
Edge: int(13) -> var(some_value2) # var:some_value2
Edge: int(13) -> var(some_value2) # var:some_value2
Edge: int(2) -> var(num) # var:num
Edge: int(3) -> var(num) # var:num
Edge: int(4) -> call:_operator(str("+"), call:_operator(str("+"), var(some_value1), var(some_value2)), int(4)) # b
Edge: int(4) -> call:_operator(str("+"), call:_operator(str("+"), var(some_value1), var(some_value2)), int(4)) # b
Edge: int(4) -> call:_operator(str("+"), call:_operator(str("+"), var(some_value1), var(some_value2)), int(4)) # b
Edge: int(42) -> var(some_value1) # var:some_value1
Edge: int(42) -> var(some_value1) # var:some_value1
Edge: int(42) -> var(some_value1) # var:some_value1
Edge: str("+") -> call:_operator(str("+"), call:_operator(str("+"), var(some_value1), var(some_value2)), int(4)) # op
Edge: str("+") -> call:_operator(str("+"), call:_operator(str("+"), var(some_value1), var(some_value2)), int(4)) # op
Edge: str("+") -> call:_operator(str("+"), call:_operator(str("+"), var(some_value1), var(some_value2)), int(4)) # op
Edge: str("+") -> call:_operator(str("+"), var(some_value1), var(some_value2)) # op
Edge: str("+") -> call:_operator(str("+"), var(some_value1), var(some_value2)) # op
Edge: str("+") -> call:_operator(str("+"), var(some_value1), var(some_value2)) # op
Edge: str("test-%d-%d") -> call:fmt.printf(str("test-%d-%d"), var(num), var(inside)) # format
Edge: str("test-%d-%d") -> call:fmt.printf(str("test-%d-%d"), var(num), var(inside)) # format
Edge: str("test-%d-%d") -> call:fmt.printf(str("test-%d-%d"), var(num), var(inside)) # format
Edge: var(inside) -> call:fmt.printf(str("test-%d-%d"), var(num), var(inside)) # b
Edge: var(inside) -> call:fmt.printf(str("test-%d-%d"), var(num), var(inside)) # b
Edge: var(inside) -> call:fmt.printf(str("test-%d-%d"), var(num), var(inside)) # b
Edge: var(num) -> call:fmt.printf(str("test-%d-%d"), var(num), var(inside)) # a
Edge: var(num) -> call:fmt.printf(str("test-%d-%d"), var(num), var(inside)) # a
Edge: var(num) -> call:fmt.printf(str("test-%d-%d"), var(num), var(inside)) # a
Edge: var(some_value1) -> call:_operator(str("+"), var(some_value1), var(some_value2)) # a
Edge: var(some_value1) -> call:_operator(str("+"), var(some_value1), var(some_value2)) # a
Edge: var(some_value1) -> call:_operator(str("+"), var(some_value1), var(some_value2)) # a
Edge: var(some_value2) -> call:_operator(str("+"), var(some_value1), var(some_value2)) # b
Edge: var(some_value2) -> call:_operator(str("+"), var(some_value1), var(some_value2)) # b
Edge: var(some_value2) -> call:_operator(str("+"), var(some_value1), var(some_value2)) # b
Vertex: call:_operator(str("+"), call:_operator(str("+"), var(some_value1), var(some_value2)), int(4))
Vertex: call:_operator(str("+"), call:_operator(str("+"), var(some_value1), var(some_value2)), int(4))
Vertex: call:_operator(str("+"), call:_operator(str("+"), var(some_value1), var(some_value2)), int(4))
Vertex: call:_operator(str("+"), var(some_value1), var(some_value2))
Vertex: call:_operator(str("+"), var(some_value1), var(some_value2))
Vertex: call:_operator(str("+"), var(some_value1), var(some_value2))
Vertex: call:fmt.printf(str("test-%d-%d"), var(num), var(inside))
Vertex: call:fmt.printf(str("test-%d-%d"), var(num), var(inside))
Vertex: call:fmt.printf(str("test-%d-%d"), var(num), var(inside))
Vertex: int(1)
Vertex: int(13)
Vertex: int(2)
Vertex: int(3)
Vertex: int(4)
Vertex: int(42)
Vertex: str("+")
Vertex: str("+")
Vertex: str("test-%d-%d")
Vertex: var(inside)
Vertex: var(inside)
Vertex: var(inside)
Vertex: var(num)
Vertex: var(num)
Vertex: var(num)
Vertex: var(some_value1)
Vertex: var(some_value1)
Vertex: var(some_value1)
Vertex: var(some_value2)
Vertex: var(some_value2)
Vertex: var(some_value2)
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: call
Vertex: call
Vertex: call
Vertex: call
Vertex: call
Vertex: call
Vertex: call
Vertex: call
Vertex: call
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const

View File

@@ -8,14 +8,7 @@ class c1($a) {
}
$foo = "hey"
-- OUTPUT --
Edge: str("hey") -> var(foo) # var:foo
Edge: str("hey") -> var(foo) # var:foo
Edge: str("t1") -> var(a) # var:a
Edge: str("t2") -> var(a) # var:a
Vertex: str("hey")
Vertex: str("t1")
Vertex: str("t2")
Vertex: var(a)
Vertex: var(a)
Vertex: var(foo)
Vertex: var(foo)
Vertex: const
Vertex: const
Vertex: const
Vertex: const

View File

@@ -17,13 +17,14 @@ pkg "cowsay" {
state => "newest",
}
-- OUTPUT --
Edge: str("hello world") -> call:fmt.printf(str("hello world")) # format
Vertex: call:fmt.printf(str("hello world"))
Vertex: str("/tmp/foo")
Vertex: str("/tmp/foo")
Vertex: str("cowsay")
Vertex: str("cowsay")
Vertex: str("hello world")
Vertex: str("hello world")
Vertex: str("installed")
Vertex: str("newest")
Edge: FuncValue -> call # fn
Vertex: FuncValue
Vertex: call
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const

View File

@@ -10,33 +10,11 @@ $out2 = $prefixer("b")
test $out1 {} # helloa
test $out2 {} # hellob
-- OUTPUT --
Edge: call:_operator(str("+"), str("hello"), var(x)) -> func(x) { call:_operator(str("+"), str("hello"), var(x)) } # body
Edge: call:_operator(str("+"), str("hello"), var(x)) -> func(x) { call:_operator(str("+"), str("hello"), var(x)) } # body
Edge: call:prefixer(str("a")) -> var(out1) # var:out1
Edge: call:prefixer(str("b")) -> var(out2) # var:out2
Edge: func(x) { call:_operator(str("+"), str("hello"), var(x)) } -> call:prefixer(str("a")) # call:prefixer
Edge: func(x) { call:_operator(str("+"), str("hello"), var(x)) } -> call:prefixer(str("b")) # call:prefixer
Edge: str("+") -> call:_operator(str("+"), str("hello"), var(x)) # op
Edge: str("+") -> call:_operator(str("+"), str("hello"), var(x)) # op
Edge: str("a") -> call:prefixer(str("a")) # x
Edge: str("a") -> var(x) # var:x
Edge: str("b") -> call:prefixer(str("b")) # x
Edge: str("b") -> var(x) # var:x
Edge: str("hello") -> call:_operator(str("+"), str("hello"), var(x)) # a
Edge: str("hello") -> call:_operator(str("+"), str("hello"), var(x)) # a
Edge: var(x) -> call:_operator(str("+"), str("hello"), var(x)) # b
Edge: var(x) -> call:_operator(str("+"), str("hello"), var(x)) # b
Vertex: call:_operator(str("+"), str("hello"), var(x))
Vertex: call:_operator(str("+"), str("hello"), var(x))
Vertex: call:prefixer(str("a"))
Vertex: call:prefixer(str("b"))
Vertex: func(x) { call:_operator(str("+"), str("hello"), var(x)) }
Vertex: func(x) { call:_operator(str("+"), str("hello"), var(x)) }
Vertex: str("+")
Vertex: str("a")
Vertex: str("b")
Vertex: str("hello")
Vertex: var(out1)
Vertex: var(out2)
Vertex: var(x)
Vertex: var(x)
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Vertex: FuncValue
Vertex: FuncValue
Vertex: call
Vertex: call
Vertex: const
Vertex: const

View File

@@ -9,14 +9,12 @@ test $names {}
# multiples resources, defined by list
test ["hello", "world",] {}
-- OUTPUT --
Edge: list(str("hey")) -> var(names) # var:names
Edge: str("hello") -> list(str("hello"), str("world")) # 0
Edge: str("hey") -> list(str("hey")) # 0
Edge: str("world") -> list(str("hello"), str("world")) # 1
Vertex: list(str("hello"), str("world"))
Vertex: list(str("hey"))
Vertex: str("hello")
Vertex: str("hey")
Vertex: str("name")
Vertex: str("world")
Vertex: var(names)
Edge: const -> composite # 0
Edge: const -> composite # 0
Edge: const -> composite # 1
Vertex: composite
Vertex: composite
Vertex: const
Vertex: const
Vertex: const
Vertex: const

View File

@@ -0,0 +1,2 @@
-- main.mcl --
-- OUTPUT --

View File

@@ -0,0 +1,5 @@
-- main.mcl --
# TODO: this should fail with an unused variable error!
$x = 42
$y = $x
-- OUTPUT --

View File

@@ -0,0 +1,13 @@
-- main.mcl --
# this should be okay, because var is shadowed
$x = "hello"
if true {
$x = "world" # shadowed
}
test "t" {
stringptr => $x,
}
-- OUTPUT --
Vertex: const
Vertex: const
Vertex: const

View File

@@ -0,0 +1,14 @@
-- main.mcl --
# variable shadowing inner
# this should be okay, because var is shadowed
$x = "hello"
if true {
$x = "world" # shadowed
test "t" {
stringptr => $x,
}
}
-- OUTPUT --
Vertex: const
Vertex: const
Vertex: const

View File

@@ -0,0 +1,19 @@
-- main.mcl --
# variable shadowing both
# this should be okay, because var is shadowed
$x = "hello"
if true {
$x = "world" # shadowed
test "t2" {
stringptr => $x,
}
}
test "t1" {
stringptr => $x,
}
-- OUTPUT --
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const

View File

@@ -0,0 +1,14 @@
-- main.mcl --
# duplicate resource
# these two are allowed because they are compatible
pkg "cowsay" {
state => "installed",
}
pkg "cowsay" {
state => "newest",
}
-- OUTPUT --
Vertex: const
Vertex: const
Vertex: const
Vertex: const

View File

@@ -0,0 +1,7 @@
-- main.mcl --
# variable re-declaration and type change error
# this should fail b/c of variable re-declaration
$x = "wow"
$x = 99 # woops, but also a change of type :P
-- OUTPUT --
# err: errSetScope: var `x` already exists in this scope

View File

@@ -0,0 +1,6 @@
-- main.mcl --
# self-referential vars
$x = $y
$y = $x
-- OUTPUT --
# err: errSetScope: recursive reference while setting scope: not a dag

View File

@@ -0,0 +1,11 @@
-- main.mcl --
# chained vars
test "t" {
int64ptr => $c,
}
$c = $b
$b = $a
$a = 42
-- OUTPUT --
Vertex: const
Vertex: const

View File

@@ -0,0 +1,7 @@
-- main.mcl --
# simple bool
if $b {
}
$b = true
-- OUTPUT --
Vertex: const

View File

@@ -0,0 +1,13 @@
-- main.mcl --
# simple operator
test "t" {
int64ptr => 42 + 13,
}
-- OUTPUT --
Edge: FuncValue -> call # fn
Vertex: FuncValue
Vertex: call
Vertex: const
Vertex: const
Vertex: const
Vertex: const

View File

@@ -0,0 +1,18 @@
-- main.mcl --
# simple operators
test "t" {
int64ptr => 42 + 13 - 99,
}
-- OUTPUT --
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Vertex: FuncValue
Vertex: FuncValue
Vertex: call
Vertex: call
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const

View File

@@ -0,0 +1,18 @@
-- main.mcl --
# nested resource and scoped var
if true {
test "t" {
int64ptr => $x,
}
$x = 42 + $i
}
$i = 13
-- OUTPUT --
Edge: FuncValue -> call # fn
Vertex: FuncValue
Vertex: call
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const

View File

@@ -0,0 +1,9 @@
-- main.mcl --
# should be out of scope, and a compile error!
if $b {
}
if true {
$b = true
}
-- OUTPUT --
# err: errSetScope: variable b not in scope

View File

@@ -0,0 +1,6 @@
-- main.mcl --
# this should fail b/c of variable re-declaration
$x = "hello"
$x = "world" # woops
-- OUTPUT --
# err: errSetScope: var `x` already exists in this scope

View File

@@ -7,11 +7,9 @@ test "greeting" {
anotherstr => fmt.printf("hello: %s", $s),
}
-- OUTPUT --
Edge: str("hello: %s") -> call:fmt.printf(str("hello: %s"), var(s)) # format
Edge: str("world") -> var(s) # var:s
Edge: var(s) -> call:fmt.printf(str("hello: %s"), var(s)) # a
Vertex: call:fmt.printf(str("hello: %s"), var(s))
Vertex: str("greeting")
Vertex: str("hello: %s")
Vertex: str("world")
Vertex: var(s)
Edge: FuncValue -> call # fn
Vertex: FuncValue
Vertex: call
Vertex: const
Vertex: const
Vertex: const

View File

@@ -16,13 +16,13 @@ class xclass {
}
}
-- OUTPUT --
Edge: call:os.is_debian() -> if( call:os.is_debian() ) { str("bbb") } else { str("ccc") } # c
Edge: if( call:os.is_debian() ) { str("bbb") } else { str("ccc") } -> var(aaa) # var:aaa
Edge: str("bbb") -> if( call:os.is_debian() ) { str("bbb") } else { str("ccc") } # a
Edge: str("ccc") -> if( call:os.is_debian() ) { str("bbb") } else { str("ccc") } # b
Vertex: call:os.is_debian()
Vertex: if( call:os.is_debian() ) { str("bbb") } else { str("ccc") }
Vertex: str("bbb")
Vertex: str("ccc")
Vertex: str("hello")
Vertex: var(aaa)
Edge: FuncValue -> call # fn
Edge: call -> if # c
Edge: const -> if # a
Edge: const -> if # b
Vertex: FuncValue
Vertex: call
Vertex: const
Vertex: const
Vertex: const
Vertex: if

View File

@@ -16,4 +16,4 @@ class xclass {
}
}
-- OUTPUT --
# err: errSetScope: import scope `second.mcl` failed: local import of `second.mcl` failed: could not set scope from import: func `os.is_debian` does not exist in this scope
# err: errSetScope: func `os.is_debian` does not exist in this scope

View File

@@ -15,13 +15,13 @@ class xclass {
}
}
-- OUTPUT --
Edge: call:os.is_debian() -> if( call:os.is_debian() ) { str("bbb") } else { str("ccc") } # c
Edge: if( call:os.is_debian() ) { str("bbb") } else { str("ccc") } -> var(aaa) # var:aaa
Edge: str("bbb") -> if( call:os.is_debian() ) { str("bbb") } else { str("ccc") } # a
Edge: str("ccc") -> if( call:os.is_debian() ) { str("bbb") } else { str("ccc") } # b
Vertex: call:os.is_debian()
Vertex: if( call:os.is_debian() ) { str("bbb") } else { str("ccc") }
Vertex: str("bbb")
Vertex: str("ccc")
Vertex: str("hello")
Vertex: var(aaa)
Edge: FuncValue -> call # fn
Edge: call -> if # c
Edge: const -> if # a
Edge: const -> if # b
Vertex: FuncValue
Vertex: call
Vertex: const
Vertex: const
Vertex: const
Vertex: if

View File

@@ -12,48 +12,14 @@ $out2 = $prefixer($out1)
test $out1 {}
test $out2 {}
-- OUTPUT --
Edge: call:_operator(str("+"), call:_operator(str("+"), var(prefix), str(":")), var(x)) -> func(x) { call:_operator(str("+"), call:_operator(str("+"), var(prefix), str(":")), var(x)) } # body
Edge: call:_operator(str("+"), call:_operator(str("+"), var(prefix), str(":")), var(x)) -> func(x) { call:_operator(str("+"), call:_operator(str("+"), var(prefix), str(":")), var(x)) } # body
Edge: call:_operator(str("+"), var(prefix), str(":")) -> call:_operator(str("+"), call:_operator(str("+"), var(prefix), str(":")), var(x)) # a
Edge: call:_operator(str("+"), var(prefix), str(":")) -> call:_operator(str("+"), call:_operator(str("+"), var(prefix), str(":")), var(x)) # a
Edge: call:prefixer(str("world")) -> var(out1) # var:out1
Edge: call:prefixer(str("world")) -> var(out1) # var:out1
Edge: call:prefixer(var(out1)) -> var(out2) # var:out2
Edge: func(x) { call:_operator(str("+"), call:_operator(str("+"), var(prefix), str(":")), var(x)) } -> call:prefixer(str("world")) # call:prefixer
Edge: func(x) { call:_operator(str("+"), call:_operator(str("+"), var(prefix), str(":")), var(x)) } -> call:prefixer(var(out1)) # call:prefixer
Edge: str("+") -> call:_operator(str("+"), call:_operator(str("+"), var(prefix), str(":")), var(x)) # op
Edge: str("+") -> call:_operator(str("+"), call:_operator(str("+"), var(prefix), str(":")), var(x)) # op
Edge: str("+") -> call:_operator(str("+"), var(prefix), str(":")) # op
Edge: str("+") -> call:_operator(str("+"), var(prefix), str(":")) # op
Edge: str(":") -> call:_operator(str("+"), var(prefix), str(":")) # b
Edge: str(":") -> call:_operator(str("+"), var(prefix), str(":")) # b
Edge: str("hello") -> var(prefix) # var:prefix
Edge: str("hello") -> var(prefix) # var:prefix
Edge: str("world") -> call:prefixer(str("world")) # x
Edge: str("world") -> var(x) # var:x
Edge: var(out1) -> call:prefixer(var(out1)) # x
Edge: var(out1) -> var(x) # var:x
Edge: var(prefix) -> call:_operator(str("+"), var(prefix), str(":")) # a
Edge: var(prefix) -> call:_operator(str("+"), var(prefix), str(":")) # a
Edge: var(x) -> call:_operator(str("+"), call:_operator(str("+"), var(prefix), str(":")), var(x)) # b
Edge: var(x) -> call:_operator(str("+"), call:_operator(str("+"), var(prefix), str(":")), var(x)) # b
Vertex: call:_operator(str("+"), call:_operator(str("+"), var(prefix), str(":")), var(x))
Vertex: call:_operator(str("+"), call:_operator(str("+"), var(prefix), str(":")), var(x))
Vertex: call:_operator(str("+"), var(prefix), str(":"))
Vertex: call:_operator(str("+"), var(prefix), str(":"))
Vertex: call:prefixer(str("world"))
Vertex: call:prefixer(var(out1))
Vertex: func(x) { call:_operator(str("+"), call:_operator(str("+"), var(prefix), str(":")), var(x)) }
Vertex: func(x) { call:_operator(str("+"), call:_operator(str("+"), var(prefix), str(":")), var(x)) }
Vertex: str("+")
Vertex: str("+")
Vertex: str(":")
Vertex: str("hello")
Vertex: str("world")
Vertex: var(out1)
Vertex: var(out1)
Vertex: var(out2)
Vertex: var(prefix)
Vertex: var(prefix)
Vertex: var(x)
Vertex: var(x)
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: call
Vertex: call
Vertex: call
Vertex: const
Vertex: const

View File

@@ -62,67 +62,42 @@ $ex1 = $example1.name
$name = "i am github.com/purpleidea/mgmt-example2/ and i contain: " + $ex1
-- OUTPUT --
Edge: call:_operator(str("+"), int(42), var(third.three)) -> var(h2g2.answer) # var:h2g2.answer
Edge: call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) -> var(example1.name) # var:example1.name
Edge: call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) -> var(example1.name) # var:example1.name
Edge: call:_operator(str("+"), str("this is module mod1 which contains: "), var(mod1.name)) -> var(mod1.name) # var:mod1.name
Edge: int(3) -> var(third.three) # var:third.three
Edge: int(42) -> call:_operator(str("+"), int(42), var(third.three)) # a
Edge: str("+") -> call:_operator(str("+"), int(42), var(third.three)) # op
Edge: str("+") -> call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) # op
Edge: str("+") -> call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) # op
Edge: str("+") -> call:_operator(str("+"), str("this is module mod1 which contains: "), var(mod1.name)) # op
Edge: str("i am github.com/purpleidea/mgmt-example1/ and i contain: ") -> call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) # a
Edge: str("i am github.com/purpleidea/mgmt-example1/ and i contain: ") -> call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) # a
Edge: str("i imported local: %s") -> call:fmt.printf(str("i imported local: %s"), var(mod1.name)) # format
Edge: str("i imported remote: %s and %s") -> call:fmt.printf(str("i imported remote: %s and %s"), var(example1.name), var(example2.ex1)) # format
Edge: str("the answer is: %d") -> call:fmt.printf(str("the answer is: %d"), var(answer)) # format
Edge: str("this is module mod1 which contains: ") -> call:_operator(str("+"), str("this is module mod1 which contains: "), var(mod1.name)) # a
Edge: str("this is the nested git module mod1") -> var(mod1.name) # var:mod1.name
Edge: str("this is the nested git module mod1") -> var(mod1.name) # var:mod1.name
Edge: str("this is the nested local module mod1") -> var(mod1.name) # var:mod1.name
Edge: var(answer) -> call:fmt.printf(str("the answer is: %d"), var(answer)) # a
Edge: var(example1.name) -> call:fmt.printf(str("i imported remote: %s and %s"), var(example1.name), var(example2.ex1)) # a
Edge: var(example1.name) -> var(example2.ex1) # var:example2.ex1
Edge: var(example2.ex1) -> call:fmt.printf(str("i imported remote: %s and %s"), var(example1.name), var(example2.ex1)) # b
Edge: var(h2g2.answer) -> var(answer) # var:answer
Edge: var(mod1.name) -> call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) # b
Edge: var(mod1.name) -> call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) # b
Edge: var(mod1.name) -> call:_operator(str("+"), str("this is module mod1 which contains: "), var(mod1.name)) # b
Edge: var(mod1.name) -> call:fmt.printf(str("i imported local: %s"), var(mod1.name)) # a
Edge: var(third.three) -> call:_operator(str("+"), int(42), var(third.three)) # b
Vertex: call:_operator(str("+"), int(42), var(third.three))
Vertex: call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name))
Vertex: call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name))
Vertex: call:_operator(str("+"), str("this is module mod1 which contains: "), var(mod1.name))
Vertex: call:fmt.printf(str("i imported local: %s"), var(mod1.name))
Vertex: call:fmt.printf(str("i imported remote: %s and %s"), var(example1.name), var(example2.ex1))
Vertex: call:fmt.printf(str("the answer is: %d"), var(answer))
Vertex: int(3)
Vertex: int(42)
Vertex: str("+")
Vertex: str("+")
Vertex: str("+")
Vertex: str("+")
Vertex: str("hello")
Vertex: str("hello2")
Vertex: str("hello3")
Vertex: str("i am github.com/purpleidea/mgmt-example1/ and i contain: ")
Vertex: str("i am github.com/purpleidea/mgmt-example1/ and i contain: ")
Vertex: str("i imported local: %s")
Vertex: str("i imported remote: %s and %s")
Vertex: str("the answer is: %d")
Vertex: str("this is module mod1 which contains: ")
Vertex: str("this is the nested git module mod1")
Vertex: str("this is the nested git module mod1")
Vertex: str("this is the nested local module mod1")
Vertex: var(answer)
Vertex: var(example1.name)
Vertex: var(example1.name)
Vertex: var(example2.ex1)
Vertex: var(h2g2.answer)
Vertex: var(mod1.name)
Vertex: var(mod1.name)
Vertex: var(mod1.name)
Vertex: var(mod1.name)
Vertex: var(third.three)
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: call
Vertex: call
Vertex: call
Vertex: call
Vertex: call
Vertex: call
Vertex: call
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const

View File

@@ -10,34 +10,29 @@ class c1($a, $b) {
}
}
-- OUTPUT --
Edge: call:len(var(b)) -> call:fmt.printf(str("len is: %d"), call:len(var(b))) # a
Edge: call:len(var(b)) -> call:fmt.printf(str("len is: %d"), call:len(var(b))) # a
Edge: int(-37) -> list(int(13), int(42), int(0), int(-37)) # 3
Edge: int(0) -> list(int(13), int(42), int(0), int(-37)) # 2
Edge: int(13) -> list(int(13), int(42), int(0), int(-37)) # 0
Edge: int(42) -> list(int(13), int(42), int(0), int(-37)) # 1
Edge: list(int(13), int(42), int(0), int(-37)) -> var(b) # var:b
Edge: str("hello") -> var(b) # var:b
Edge: str("len is: %d") -> call:fmt.printf(str("len is: %d"), call:len(var(b))) # format
Edge: str("len is: %d") -> call:fmt.printf(str("len is: %d"), call:len(var(b))) # format
Edge: str("t1") -> var(a) # var:a
Edge: str("t2") -> var(a) # var:a
Edge: var(b) -> call:len(var(b)) # 0
Edge: var(b) -> call:len(var(b)) # 0
Vertex: call:fmt.printf(str("len is: %d"), call:len(var(b)))
Vertex: call:fmt.printf(str("len is: %d"), call:len(var(b)))
Vertex: call:len(var(b))
Vertex: call:len(var(b))
Vertex: int(-37)
Vertex: int(0)
Vertex: int(13)
Vertex: int(42)
Vertex: list(int(13), int(42), int(0), int(-37))
Vertex: str("hello")
Vertex: str("len is: %d")
Vertex: str("t1")
Vertex: str("t2")
Vertex: var(a)
Vertex: var(a)
Vertex: var(b)
Vertex: var(b)
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: const -> composite # 0
Edge: const -> composite # 1
Edge: const -> composite # 2
Edge: const -> composite # 3
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: call
Vertex: call
Vertex: call
Vertex: call
Vertex: composite
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const

View File

@@ -60,67 +60,42 @@ $ex1 = $example1.name
$name = "i am github.com/purpleidea/mgmt-example2/ and i contain: " + $ex1
-- OUTPUT --
Edge: call:_operator(str("+"), int(42), var(third.three)) -> var(h2g2.answer) # var:h2g2.answer
Edge: call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) -> var(example1.name) # var:example1.name
Edge: call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) -> var(example1.name) # var:example1.name
Edge: call:_operator(str("+"), str("this is module mod1 which contains: "), var(mod1.name)) -> var(mod1.name) # var:mod1.name
Edge: int(3) -> var(third.three) # var:third.three
Edge: int(42) -> call:_operator(str("+"), int(42), var(third.three)) # a
Edge: str("+") -> call:_operator(str("+"), int(42), var(third.three)) # op
Edge: str("+") -> call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) # op
Edge: str("+") -> call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) # op
Edge: str("+") -> call:_operator(str("+"), str("this is module mod1 which contains: "), var(mod1.name)) # op
Edge: str("i am github.com/purpleidea/mgmt-example1/ and i contain: ") -> call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) # a
Edge: str("i am github.com/purpleidea/mgmt-example1/ and i contain: ") -> call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) # a
Edge: str("i imported local: %s") -> call:fmt.printf(str("i imported local: %s"), var(mod1.name)) # format
Edge: str("i imported remote: %s and %s") -> call:fmt.printf(str("i imported remote: %s and %s"), var(example1.name), var(example2.ex1)) # format
Edge: str("the answer is: %d") -> call:fmt.printf(str("the answer is: %d"), var(answer)) # format
Edge: str("this is module mod1 which contains: ") -> call:_operator(str("+"), str("this is module mod1 which contains: "), var(mod1.name)) # a
Edge: str("this is the nested git module mod1") -> var(mod1.name) # var:mod1.name
Edge: str("this is the nested git module mod1") -> var(mod1.name) # var:mod1.name
Edge: str("this is the nested local module mod1") -> var(mod1.name) # var:mod1.name
Edge: var(answer) -> call:fmt.printf(str("the answer is: %d"), var(answer)) # a
Edge: var(example1.name) -> call:fmt.printf(str("i imported remote: %s and %s"), var(example1.name), var(example2.ex1)) # a
Edge: var(example1.name) -> var(example2.ex1) # var:example2.ex1
Edge: var(example2.ex1) -> call:fmt.printf(str("i imported remote: %s and %s"), var(example1.name), var(example2.ex1)) # b
Edge: var(h2g2.answer) -> var(answer) # var:answer
Edge: var(mod1.name) -> call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) # b
Edge: var(mod1.name) -> call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) # b
Edge: var(mod1.name) -> call:_operator(str("+"), str("this is module mod1 which contains: "), var(mod1.name)) # b
Edge: var(mod1.name) -> call:fmt.printf(str("i imported local: %s"), var(mod1.name)) # a
Edge: var(third.three) -> call:_operator(str("+"), int(42), var(third.three)) # b
Vertex: call:_operator(str("+"), int(42), var(third.three))
Vertex: call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name))
Vertex: call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name))
Vertex: call:_operator(str("+"), str("this is module mod1 which contains: "), var(mod1.name))
Vertex: call:fmt.printf(str("i imported local: %s"), var(mod1.name))
Vertex: call:fmt.printf(str("i imported remote: %s and %s"), var(example1.name), var(example2.ex1))
Vertex: call:fmt.printf(str("the answer is: %d"), var(answer))
Vertex: int(3)
Vertex: int(42)
Vertex: str("+")
Vertex: str("+")
Vertex: str("+")
Vertex: str("+")
Vertex: str("hello")
Vertex: str("hello2")
Vertex: str("hello3")
Vertex: str("i am github.com/purpleidea/mgmt-example1/ and i contain: ")
Vertex: str("i am github.com/purpleidea/mgmt-example1/ and i contain: ")
Vertex: str("i imported local: %s")
Vertex: str("i imported remote: %s and %s")
Vertex: str("the answer is: %d")
Vertex: str("this is module mod1 which contains: ")
Vertex: str("this is the nested git module mod1")
Vertex: str("this is the nested git module mod1")
Vertex: str("this is the nested local module mod1")
Vertex: var(answer)
Vertex: var(example1.name)
Vertex: var(example1.name)
Vertex: var(example2.ex1)
Vertex: var(h2g2.answer)
Vertex: var(mod1.name)
Vertex: var(mod1.name)
Vertex: var(mod1.name)
Vertex: var(mod1.name)
Vertex: var(third.three)
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: call
Vertex: call
Vertex: call
Vertex: call
Vertex: call
Vertex: call
Vertex: call
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const

View File

@@ -1,24 +1,62 @@
-- main.mcl --
# XXX: should error at graph unification, but we have a type unification bug
#test "test" {
# anotherstr => "test",
#
# Meta => true ?: struct{
# noop => false,
# retry => -1,
# delay => 0,
# poll => 5,
# limit => 4.2,
# burst => 3,
# sema => ["foo:1", "bar:3",],
# rewatch => false,
# realize => true,
# reverse => true,
# autoedge => true,
# autogroup => true,
# },
# Meta => true ?: struct{
# noop => false,
# },
#}
test "test" {
anotherstr => "test",
Meta => true ?: struct{
noop => false,
retry => -1,
retryreset => false,
delay => 0,
poll => 5,
limit => 4.2,
burst => 3,
reset => false,
sema => ["foo:1", "bar:3",],
rewatch => false,
realize => true,
reverse => true,
autoedge => true,
autogroup => true,
},
# XXX: should error at graph unification, but we have a type unification bug
#Meta => true ?: struct{
# noop => false,
#},
}
-- OUTPUT --
Edge: composite -> composite # sema
Edge: const -> composite # 0
Edge: const -> composite # 1
Edge: const -> composite # autoedge
Edge: const -> composite # autogroup
Edge: const -> composite # burst
Edge: const -> composite # delay
Edge: const -> composite # limit
Edge: const -> composite # noop
Edge: const -> composite # poll
Edge: const -> composite # realize
Edge: const -> composite # reset
Edge: const -> composite # retry
Edge: const -> composite # retryreset
Edge: const -> composite # reverse
Edge: const -> composite # rewatch
Vertex: composite
Vertex: composite
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const

View File

@@ -11,14 +11,8 @@ $out = $fn()
test $out {}
-- OUTPUT --
Edge: call:fn() -> var(out) # var:out
Edge: call:funcgen() -> call:fn() # call:fn
Edge: func() { func() { str("hello") } } -> call:funcgen() # call:funcgen
Edge: func() { str("hello") } -> func() { func() { str("hello") } } # body
Edge: str("hello") -> func() { str("hello") } # body
Vertex: call:fn()
Vertex: call:funcgen()
Vertex: func() { func() { str("hello") } }
Vertex: func() { str("hello") }
Vertex: str("hello")
Vertex: var(out)
Edge: FuncValue -> call # fn
Edge: call -> call # fn
Vertex: FuncValue
Vertex: call
Vertex: call

View File

@@ -10,14 +10,8 @@ $out = $fn()
test $out {}
-- OUTPUT --
Edge: call:fn() -> var(out) # var:out
Edge: call:funcgen() -> call:fn() # call:fn
Edge: func() { func() { str("hello") } } -> call:funcgen() # call:funcgen
Edge: func() { str("hello") } -> func() { func() { str("hello") } } # body
Edge: str("hello") -> func() { str("hello") } # body
Vertex: call:fn()
Vertex: call:funcgen()
Vertex: func() { func() { str("hello") } }
Vertex: func() { str("hello") }
Vertex: str("hello")
Vertex: var(out)
Edge: FuncValue -> call # fn
Edge: call -> call # fn
Vertex: FuncValue
Vertex: call
Vertex: call

View File

@@ -6,7 +6,5 @@ if true {
}
test $x {}
-- OUTPUT --
Edge: str("hello") -> var(x) # var:x
Vertex: bool(true)
Vertex: str("hello")
Vertex: var(x)
Vertex: const
Vertex: const

View File

@@ -6,7 +6,5 @@ if true {
test $x {}
}
-- OUTPUT --
Edge: str("world") -> var(x) # var:x
Vertex: bool(true)
Vertex: str("world")
Vertex: var(x)
Vertex: const
Vertex: const

View File

@@ -7,10 +7,6 @@ $out1 = answer()
test $out1 {}
-- OUTPUT --
Edge: call:answer() -> var(out1) # var:out1
Edge: func() { str("the answer is 42") } -> call:answer() # call:answer
Edge: str("the answer is 42") -> func() { str("the answer is 42") } # body
Vertex: call:answer()
Vertex: func() { str("the answer is 42") }
Vertex: str("the answer is 42")
Vertex: var(out1)
Edge: FuncValue -> call # fn
Vertex: FuncValue
Vertex: call

View File

@@ -8,19 +8,13 @@ $out2 = answer()
test $out1 + $out2 {}
-- OUTPUT --
Edge: call:answer() -> var(out1) # var:out1
Edge: call:answer() -> var(out2) # var:out2
Edge: func() { str("the answer is 42") } -> call:answer() # call:answer
Edge: func() { str("the answer is 42") } -> call:answer() # call:answer
Edge: str("+") -> call:_operator(str("+"), var(out1), var(out2)) # op
Edge: str("the answer is 42") -> func() { str("the answer is 42") } # body
Edge: var(out1) -> call:_operator(str("+"), var(out1), var(out2)) # a
Edge: var(out2) -> call:_operator(str("+"), var(out1), var(out2)) # b
Vertex: call:_operator(str("+"), var(out1), var(out2))
Vertex: call:answer()
Vertex: call:answer()
Vertex: func() { str("the answer is 42") }
Vertex: str("+")
Vertex: str("the answer is 42")
Vertex: var(out1)
Vertex: var(out2)
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: call
Vertex: call
Vertex: call
Vertex: const

View File

@@ -10,10 +10,6 @@ $out = $answer()
test $out {}
-- OUTPUT --
Edge: call:answer() -> var(out) # var:out
Edge: func() { str("the answer is 42") } -> call:answer() # call:answer
Edge: str("the answer is 42") -> func() { str("the answer is 42") } # body
Vertex: call:answer()
Vertex: func() { str("the answer is 42") }
Vertex: str("the answer is 42")
Vertex: var(out)
Edge: FuncValue -> call # fn
Vertex: FuncValue
Vertex: call

View File

@@ -11,19 +11,13 @@ $out2 = $answer()
test $out1 + $out2 {}
-- OUTPUT --
Edge: call:answer() -> var(out1) # var:out1
Edge: call:answer() -> var(out2) # var:out2
Edge: func() { str("the answer is 42") } -> call:answer() # call:answer
Edge: func() { str("the answer is 42") } -> call:answer() # call:answer
Edge: str("+") -> call:_operator(str("+"), var(out1), var(out2)) # op
Edge: str("the answer is 42") -> func() { str("the answer is 42") } # body
Edge: var(out1) -> call:_operator(str("+"), var(out1), var(out2)) # a
Edge: var(out2) -> call:_operator(str("+"), var(out1), var(out2)) # b
Vertex: call:_operator(str("+"), var(out1), var(out2))
Vertex: call:answer()
Vertex: call:answer()
Vertex: func() { str("the answer is 42") }
Vertex: str("+")
Vertex: str("the answer is 42")
Vertex: var(out1)
Vertex: var(out2)
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: call
Vertex: call
Vertex: call
Vertex: const

View File

@@ -52,91 +52,90 @@ if $state == "three" {
Exec["timer"] -> Kv["${ns}"]
}
-- OUTPUT --
Edge: call:_operator(str("=="), var(state), str("default")) -> call:_operator(str("||"), call:_operator(str("=="), var(state), str("one")), call:_operator(str("=="), var(state), str("default"))) # b
Edge: call:_operator(str("=="), var(state), str("one")) -> call:_operator(str("||"), call:_operator(str("=="), var(state), str("one")), call:_operator(str("=="), var(state), str("default"))) # a
Edge: call:maplookup(var(exchanged), var(hostname), str("default")) -> var(state) # var:state
Edge: call:maplookup(var(exchanged), var(hostname), str("default")) -> var(state) # var:state
Edge: call:maplookup(var(exchanged), var(hostname), str("default")) -> var(state) # var:state
Edge: call:maplookup(var(exchanged), var(hostname), str("default")) -> var(state) # var:state
Edge: call:world.kvlookup(var(ns)) -> var(exchanged) # var:exchanged
Edge: str("") -> var(hostname) # var:hostname
Edge: str("==") -> call:_operator(str("=="), var(state), str("default")) # op
Edge: str("==") -> call:_operator(str("=="), var(state), str("one")) # op
Edge: str("==") -> call:_operator(str("=="), var(state), str("three")) # op
Edge: str("==") -> call:_operator(str("=="), var(state), str("two")) # op
Edge: str("default") -> call:_operator(str("=="), var(state), str("default")) # b
Edge: str("default") -> call:maplookup(var(exchanged), var(hostname), str("default")) # default
Edge: str("estate") -> var(ns) # var:ns
Edge: str("estate") -> var(ns) # var:ns
Edge: str("estate") -> var(ns) # var:ns
Edge: str("estate") -> var(ns) # var:ns
Edge: str("estate") -> var(ns) # var:ns
Edge: str("estate") -> var(ns) # var:ns
Edge: str("estate") -> var(ns) # var:ns
Edge: str("estate") -> var(ns) # var:ns
Edge: str("estate") -> var(ns) # var:ns
Edge: str("estate") -> var(ns) # var:ns
Edge: str("one") -> call:_operator(str("=="), var(state), str("one")) # b
Edge: str("three") -> call:_operator(str("=="), var(state), str("three")) # b
Edge: str("two") -> call:_operator(str("=="), var(state), str("two")) # b
Edge: str("||") -> call:_operator(str("||"), call:_operator(str("=="), var(state), str("one")), call:_operator(str("=="), var(state), str("default"))) # op
Edge: var(exchanged) -> call:maplookup(var(exchanged), var(hostname), str("default")) # map
Edge: var(hostname) -> call:maplookup(var(exchanged), var(hostname), str("default")) # key
Edge: var(ns) -> call:world.kvlookup(var(ns)) # namespace
Edge: var(state) -> call:_operator(str("=="), var(state), str("default")) # a
Edge: var(state) -> call:_operator(str("=="), var(state), str("one")) # a
Edge: var(state) -> call:_operator(str("=="), var(state), str("three")) # a
Edge: var(state) -> call:_operator(str("=="), var(state), str("two")) # a
Vertex: call:_operator(str("=="), var(state), str("default"))
Vertex: call:_operator(str("=="), var(state), str("one"))
Vertex: call:_operator(str("=="), var(state), str("three"))
Vertex: call:_operator(str("=="), var(state), str("two"))
Vertex: call:_operator(str("||"), call:_operator(str("=="), var(state), str("one")), call:_operator(str("=="), var(state), str("default")))
Vertex: call:maplookup(var(exchanged), var(hostname), str("default"))
Vertex: call:world.kvlookup(var(ns))
Vertex: str("")
Vertex: str("/tmp/mgmt/state")
Vertex: str("/tmp/mgmt/state")
Vertex: str("/tmp/mgmt/state")
Vertex: str("/usr/bin/sleep 1s")
Vertex: str("/usr/bin/sleep 1s")
Vertex: str("/usr/bin/sleep 1s")
Vertex: str("==")
Vertex: str("==")
Vertex: str("==")
Vertex: str("==")
Vertex: str("default")
Vertex: str("default")
Vertex: str("estate")
Vertex: str("one")
Vertex: str("one")
Vertex: str("state: one\n")
Vertex: str("state: three\n")
Vertex: str("state: two\n")
Vertex: str("three")
Vertex: str("three")
Vertex: str("timer")
Vertex: str("timer")
Vertex: str("timer")
Vertex: str("timer")
Vertex: str("timer")
Vertex: str("timer")
Vertex: str("two")
Vertex: str("two")
Vertex: str("||")
Vertex: var(exchanged)
Vertex: var(hostname)
Vertex: var(ns)
Vertex: var(ns)
Vertex: var(ns)
Vertex: var(ns)
Vertex: var(ns)
Vertex: var(ns)
Vertex: var(ns)
Vertex: var(ns)
Vertex: var(ns)
Vertex: var(ns)
Vertex: var(state)
Vertex: var(state)
Vertex: var(state)
Vertex: var(state)
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: call
Vertex: call
Vertex: call
Vertex: call
Vertex: call
Vertex: call
Vertex: call
Vertex: call
Vertex: call
Vertex: call
Vertex: call
Vertex: call
Vertex: call
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const
Vertex: const

View File

@@ -16,15 +16,15 @@ test "greeting3" {
anotherstr => $fn(),
}
-- OUTPUT --
Edge: func() { str("hello world") } -> call:fn() # call:fn
Edge: func() { str("hello world") } -> call:fn() # call:fn
Edge: func() { str("hello world") } -> call:fn() # call:fn
Edge: str("hello world") -> func() { str("hello world") } # body
Vertex: call:fn()
Vertex: call:fn()
Vertex: call:fn()
Vertex: func() { str("hello world") }
Vertex: str("greeting1")
Vertex: str("greeting2")
Vertex: str("greeting3")
Vertex: str("hello world")
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: call
Vertex: call
Vertex: call
Vertex: const
Vertex: const
Vertex: const

View File

@@ -18,59 +18,15 @@ test "greeting3" {
anotherstr => $fn(),
}
-- OUTPUT --
Edge: call:_operator(str("+"), call:_operator(str("+"), var(s1), str(" ")), var(s2)) -> func() { call:_operator(str("+"), call:_operator(str("+"), var(s1), str(" ")), var(s2)) } # body
Edge: call:_operator(str("+"), call:_operator(str("+"), var(s1), str(" ")), var(s2)) -> func() { call:_operator(str("+"), call:_operator(str("+"), var(s1), str(" ")), var(s2)) } # body
Edge: call:_operator(str("+"), call:_operator(str("+"), var(s1), str(" ")), var(s2)) -> func() { call:_operator(str("+"), call:_operator(str("+"), var(s1), str(" ")), var(s2)) } # body
Edge: call:_operator(str("+"), var(s1), str(" ")) -> call:_operator(str("+"), call:_operator(str("+"), var(s1), str(" ")), var(s2)) # a
Edge: call:_operator(str("+"), var(s1), str(" ")) -> call:_operator(str("+"), call:_operator(str("+"), var(s1), str(" ")), var(s2)) # a
Edge: call:_operator(str("+"), var(s1), str(" ")) -> call:_operator(str("+"), call:_operator(str("+"), var(s1), str(" ")), var(s2)) # a
Edge: func() { call:_operator(str("+"), call:_operator(str("+"), var(s1), str(" ")), var(s2)) } -> call:fn() # call:fn
Edge: func() { call:_operator(str("+"), call:_operator(str("+"), var(s1), str(" ")), var(s2)) } -> call:fn() # call:fn
Edge: func() { call:_operator(str("+"), call:_operator(str("+"), var(s1), str(" ")), var(s2)) } -> call:fn() # call:fn
Edge: str(" ") -> call:_operator(str("+"), var(s1), str(" ")) # b
Edge: str(" ") -> call:_operator(str("+"), var(s1), str(" ")) # b
Edge: str(" ") -> call:_operator(str("+"), var(s1), str(" ")) # b
Edge: str("+") -> call:_operator(str("+"), call:_operator(str("+"), var(s1), str(" ")), var(s2)) # op
Edge: str("+") -> call:_operator(str("+"), call:_operator(str("+"), var(s1), str(" ")), var(s2)) # op
Edge: str("+") -> call:_operator(str("+"), call:_operator(str("+"), var(s1), str(" ")), var(s2)) # op
Edge: str("+") -> call:_operator(str("+"), var(s1), str(" ")) # op
Edge: str("+") -> call:_operator(str("+"), var(s1), str(" ")) # op
Edge: str("+") -> call:_operator(str("+"), var(s1), str(" ")) # op
Edge: str("hello") -> var(s1) # var:s1
Edge: str("hello") -> var(s1) # var:s1
Edge: str("hello") -> var(s1) # var:s1
Edge: str("world") -> var(s2) # var:s2
Edge: str("world") -> var(s2) # var:s2
Edge: str("world") -> var(s2) # var:s2
Edge: var(s1) -> call:_operator(str("+"), var(s1), str(" ")) # a
Edge: var(s1) -> call:_operator(str("+"), var(s1), str(" ")) # a
Edge: var(s1) -> call:_operator(str("+"), var(s1), str(" ")) # a
Edge: var(s2) -> call:_operator(str("+"), call:_operator(str("+"), var(s1), str(" ")), var(s2)) # b
Edge: var(s2) -> call:_operator(str("+"), call:_operator(str("+"), var(s1), str(" ")), var(s2)) # b
Edge: var(s2) -> call:_operator(str("+"), call:_operator(str("+"), var(s1), str(" ")), var(s2)) # b
Vertex: call:_operator(str("+"), call:_operator(str("+"), var(s1), str(" ")), var(s2))
Vertex: call:_operator(str("+"), call:_operator(str("+"), var(s1), str(" ")), var(s2))
Vertex: call:_operator(str("+"), call:_operator(str("+"), var(s1), str(" ")), var(s2))
Vertex: call:_operator(str("+"), var(s1), str(" "))
Vertex: call:_operator(str("+"), var(s1), str(" "))
Vertex: call:_operator(str("+"), var(s1), str(" "))
Vertex: call:fn()
Vertex: call:fn()
Vertex: call:fn()
Vertex: func() { call:_operator(str("+"), call:_operator(str("+"), var(s1), str(" ")), var(s2)) }
Vertex: func() { call:_operator(str("+"), call:_operator(str("+"), var(s1), str(" ")), var(s2)) }
Vertex: func() { call:_operator(str("+"), call:_operator(str("+"), var(s1), str(" ")), var(s2)) }
Vertex: str(" ")
Vertex: str("+")
Vertex: str("+")
Vertex: str("greeting1")
Vertex: str("greeting2")
Vertex: str("greeting3")
Vertex: str("hello")
Vertex: str("world")
Vertex: var(s1)
Vertex: var(s1)
Vertex: var(s1)
Vertex: var(s2)
Vertex: var(s2)
Vertex: var(s2)
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: call
Vertex: call
Vertex: call
Vertex: const
Vertex: const
Vertex: const

View File

@@ -0,0 +1,10 @@
-- main.mcl --
import "fmt"
$zero = 0
$one = $zero + 1
$two = $one + 1 # needs a chain to panic
test fmt.printf("%d%d%d", $zero, $one, $two) {}
-- OUTPUT --
Vertex: test[012]

View File

@@ -1,5 +1,6 @@
-- main.mcl --
$x1 = "bad1"
$x2 = "also bad"
include defs.foo
import "defs.mcl" # out of order for fun

View File

@@ -0,0 +1,25 @@
-- main.mcl --
import "fmt"
import "iter"
# function expression
$id1 = func($x str) { # definition site
$x
}
$id2 = func($x str) {
$x + $x
}
$generate = func($idn) {
$idn("foo") # 1 call site, 2 calls
}
$foo = iter.map([$id1, $id2,], $generate)
#test $foo[0] {}
#test $foo[1] {}
test listlookup($foo, 0, "fail") {} # TODO: add syntactic sugar for listlookup
test listlookup($foo, 1, "fail") {} # TODO: add syntactic sugar for listlookup
-- OUTPUT --
Vertex: test[foo]
Vertex: test[foofoo]

View File

@@ -0,0 +1,19 @@
-- main.mcl --
$x = "top-level"
func f1() {
$x + "1"
}
$f2 = func() {
$x + "2"
}
$call_f1 = func($x) {
f1() + $x
}
$call_f2 = func($x) {
$f2() + $x
}
test $call_f1("!") {}
test $call_f2("?") {}
-- OUTPUT --
Vertex: test[top-level1!]
Vertex: test[top-level2?]

View File

@@ -0,0 +1,11 @@
-- main.mcl --
# function statement
func stradd($x) {
$x + $x
}
$x1 = stradd("hey")
test $x1 {}
-- OUTPUT --
Vertex: test[heyhey]

View File

@@ -2,20 +2,14 @@
import "fmt"
# function statement
func sq1($x, $y) {
$y + $x * $x
func sq1($x) {
$x + $x
#$x + 3
#6
}
# function expression
$sq2 = func($x, $y) {
$y + $x * $x
}
$x1 = sq1(3, 4) # 3^2 + 4 = 13
$x2 = $sq2(7, -7) # 7^2 + 2 = 42
$x1 = sq1(3) # 3^2 + 4 = 13
test fmt.printf("sq1: %d", $x1) {}
test fmt.printf("sq2: %d", $x2) {}
-- OUTPUT --
Vertex: test[sq1: 13]
Vertex: test[sq2: 42]
Vertex: test[sq1: 6]

View File

@@ -0,0 +1,17 @@
-- main.mcl --
import "fmt"
import "math"
# XXX: do the input nodes to _operator look weird here? in my testing I saw
# fortytwo appear, and then disappear before we finished running...
# function statement
func sq1($x) {
$x + 3
}
$x1 = sq1(math.fortytwo())
test fmt.printf("sq1: %d", $x1) {}
-- OUTPUT --
Vertex: test[sq1: 45]

View File

@@ -0,0 +1,13 @@
-- main.mcl --
import "fmt"
# function statement
func stradd($x) {
$x + "there"
}
$x1 = stradd("hey")
test $x1 {}
-- OUTPUT --
Vertex: test[heythere]

View File

@@ -0,0 +1,13 @@
-- main.mcl --
import "fmt"
# function statement
func stradd($x) {
"nothing"
}
$x1 = stradd("hey")
test $x1 {}
-- OUTPUT --
Vertex: test[nothing]

View File

@@ -0,0 +1,9 @@
-- main.mcl --
# function statement
func identity($x) {
$x
}
test identity("hey") {}
-- OUTPUT --
Vertex: test[hey]

View File

@@ -0,0 +1,10 @@
-- main.mcl --
$out1 = if true {
"hello"
} else {
"world"
}
test $out1 {}
-- OUTPUT --
Vertex: test[hello]

View File

@@ -0,0 +1,15 @@
-- main.mcl --
# this can return changing functions, and could be optimized, too
$fn = func($b) {
if true {
"hello"
} else {
"world"
}
}
$out1 = $fn(true)
test $out1 {}
-- OUTPUT --
Vertex: test[hello]

View File

@@ -10,4 +10,4 @@ print "msg" {
msg => fmt.printf("notfn: %d", $x),
}
-- OUTPUT --
# err: errUnify: expected: Func, got: Int
# err: errUnify: func arg count differs

View File

@@ -0,0 +1,13 @@
-- main.mcl --
import "fmt"
# function statement
$stradd = func($x) {
$x + $x
}
$x1 = $stradd("hey")
test $x1 {}
-- OUTPUT --
Vertex: test[heyhey]

View File

@@ -0,0 +1,8 @@
-- main.mcl --
$hey = func() {
"hello"
}
test $hey() {}
-- OUTPUT --
Vertex: test[hello]

View File

@@ -0,0 +1,13 @@
-- main.mcl --
import "fmt"
# function statement
$stradd = func($x) {
$x + "there"
}
$x1 = $stradd("hey")
test $x1 {}
-- OUTPUT --
Vertex: test[heythere]

View File

@@ -0,0 +1,6 @@
-- main.mcl --
import "fmt"
test fmt.printf("hello: %d", 42) {}
-- OUTPUT --
Vertex: test[hello: 42]

View File

@@ -0,0 +1,13 @@
-- main.mcl --
import "fmt"
# function statement
$stradd = func($x) {
"nothing"
}
$x1 = $stradd("hey")
test $x1 {}
-- OUTPUT --
Vertex: test[nothing]

View File

@@ -0,0 +1,10 @@
-- main.mcl --
import "iter"
$fn = func($x) { # ignore arg
"hey"
}
test iter.map([1, 2, 3,], $fn) {}
-- OUTPUT --
Vertex: test[hey]

View File

@@ -0,0 +1,13 @@
-- main.mcl --
import "fmt"
import "iter"
$fn = func($x) {
fmt.printf("hey%d", $x)
}
test iter.map([1, 2, 3,], $fn) {}
-- OUTPUT --
Vertex: test[hey1]
Vertex: test[hey2]
Vertex: test[hey3]

View File

@@ -0,0 +1,2 @@
-- main.mcl --
-- OUTPUT --

View File

@@ -0,0 +1,6 @@
-- main.mcl --
test "t1" {
stringptr => 42, # int, not str
}
-- OUTPUT --
# err: errUnify: can't unify, invariant illogicality with equals: base kind does not match (Int != Str)

View File

@@ -0,0 +1,8 @@
-- main.mcl --
test "t1" {
int64ptr => 42,
stringptr => "okay cool",
int8ptrptrptr => 127, # super nested
}
-- OUTPUT --
Vertex: test[t1]

View File

@@ -0,0 +1,13 @@
-- main.mcl --
test "t1" {
int64ptr => 42,
}
test "t2" {
int64ptr => 13,
}
Test["t1"].hello -> Test["t2"].stringptr # send/recv
-- OUTPUT --
Edge: test[t1] -> test[t2] # test[t1] -> test[t2]
Vertex: test[t1]
Vertex: test[t2]

View File

@@ -0,0 +1,37 @@
-- main.mcl --
test "t1" {
stringptr => "this is meta",
#Meta => struct{
# noop => false,
# retry => -1,
# retryreset => false,
# delay => 0,
# poll => 5,
# limit => 4.2,
# burst => 3,
# reset => false,
# sema => ["foo:1", "bar:3",],
# rewatch => false,
# realize => true,
# reverse => true,
# autoedge => true,
# autogroup => true,
#},
Meta:noop => false,
Meta:retry => -1,
Meta:retryreset => false,
Meta:delay => 0,
Meta:poll => 5,
Meta:limit => 4.2,
Meta:burst => 3,
Meta:reset => false,
Meta:sema => ["foo:1", "bar:3",],
Meta:rewatch => false,
Meta:realize => true,
Meta:reverse => true,
Meta:autoedge => true,
Meta:autogroup => true,
}
-- OUTPUT --
Vertex: test[t1]

View File

@@ -0,0 +1,8 @@
-- main.mcl --
$v = 42
$x = template("hello", $v) # redirect var for harder unification
test $x {
#anotherstr => $x,
}
-- OUTPUT --
Vertex: test[hello]

View File

@@ -0,0 +1,78 @@
-- main.mcl --
# This code should fail during type-checking.
#
# $id1 and $id2 are both polymorphic functions, which can be specialized to a
# different monomorphic type at every use site. In simple code, this
# specialization happens when the polymorphic function is called, but in more
# complex code, the specialization happens earlier, when the polymorphic
# function is passed as an argument to higher-order functions such as $generate
# and iter.map.
#
# In:
#
# $id1 = func($x str) { # definition site
# $x
# }
# $id2 = func($x str) {
# $x + $x
# }
#
# $generate = func($idn) {
# $idn("foo") # 1 call site, 2 calls
# }
#
# $foo = iter.map([$id1, $id2,], $generate)
#
# $generate is specialized to `func(func(str) str) str`, and $id1 and $id2 are
# specialized to `func(str) str`.
#
# In:
#
# $id1 = func($x) { # definition site
# $x
# }
# $id2 = func($x) {
# $x + $x
# }
#
# $generate = func($idn) {
# fmt.printf("%s %d",
# $idn("foo"), # 1 call site, 2 calls
# $idn(42)
# )
# }
#
# $foo = iter.map([$id1, $id2,], $generate)
#
# $idn cannot be given a monomorphic type, since it is used both as a
# `func(str) str` and as a `func(int) int`. Therefore, $generate cannot be
# given a monomorphic type either, and neither can the call to iter.map.
import "fmt"
import "iter"
# function expression
$id1 = func($x) { # definition site
$x
}
$id2 = func($x) {
$x + $x
}
#$str = $id1("foo")
#$int = $id1(42)
$generate = func($idn) {
fmt.printf("%s %d",
$idn("foo"), # 1 call site, 2 calls
$idn(42)
)
}
# this code should be rejected during type unification
$foo = iter.map([$id1, $id2,], $generate)
#test $foo[0] {}
test listlookup($foo, 0, "fail") {} # TODO: add syntactic sugar for listlookup
-- OUTPUT --
# err: errUnify: can't unify, invariant illogicality with equals: base kind does not match (Str != Int)