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:
@@ -21,41 +21,15 @@ $out2 = $fn2()
|
|||||||
test $out1 {}
|
test $out1 {}
|
||||||
test $out2 {}
|
test $out2 {}
|
||||||
-- OUTPUT --
|
-- OUTPUT --
|
||||||
Edge: bool(false) -> call:funcgen(bool(false)) # b
|
Edge: FuncValue -> call # fn
|
||||||
Edge: bool(false) -> var(b) # var:b
|
Edge: FuncValue -> call # fn
|
||||||
Edge: bool(true) -> call:funcgen(bool(true)) # b
|
Edge: call -> call # fn
|
||||||
Edge: bool(true) -> var(b) # var:b
|
Edge: call -> call # fn
|
||||||
Edge: call:fn1() -> var(out1) # var:out1
|
Vertex: FuncValue
|
||||||
Edge: call:fn2() -> var(out2) # var:out2
|
Vertex: FuncValue
|
||||||
Edge: call:funcgen(bool(false)) -> call:fn2() # call:fn2
|
Vertex: call
|
||||||
Edge: call:funcgen(bool(true)) -> call:fn1() # call:fn1
|
Vertex: call
|
||||||
Edge: func() { str("hello") } -> if( var(b) ) { func() { str("hello") } } else { func() { str("world") } } # a
|
Vertex: call
|
||||||
Edge: func() { str("hello") } -> if( var(b) ) { func() { str("hello") } } else { func() { str("world") } } # a
|
Vertex: call
|
||||||
Edge: func() { str("world") } -> if( var(b) ) { func() { str("hello") } } else { func() { str("world") } } # b
|
Vertex: const
|
||||||
Edge: func() { str("world") } -> if( var(b) ) { func() { str("hello") } } else { func() { str("world") } } # b
|
Vertex: const
|
||||||
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)
|
|
||||||
|
|||||||
@@ -6,20 +6,19 @@ class c1($b) {
|
|||||||
test fmt.printf("len is: %d", len($b)) {} # len is 4
|
test fmt.printf("len is: %d", len($b)) {} # len is 4
|
||||||
}
|
}
|
||||||
-- OUTPUT --
|
-- OUTPUT --
|
||||||
Edge: call:len(var(b)) -> call:fmt.printf(str("len is: %d"), call:len(var(b))) # a
|
Edge: FuncValue -> call # fn
|
||||||
Edge: int(-37) -> list(int(13), int(42), int(0), int(-37)) # 3
|
Edge: FuncValue -> call # fn
|
||||||
Edge: int(0) -> list(int(13), int(42), int(0), int(-37)) # 2
|
Edge: const -> composite # 0
|
||||||
Edge: int(13) -> list(int(13), int(42), int(0), int(-37)) # 0
|
Edge: const -> composite # 1
|
||||||
Edge: int(42) -> list(int(13), int(42), int(0), int(-37)) # 1
|
Edge: const -> composite # 2
|
||||||
Edge: list(int(13), int(42), int(0), int(-37)) -> var(b) # var:b
|
Edge: const -> composite # 3
|
||||||
Edge: str("len is: %d") -> call:fmt.printf(str("len is: %d"), call:len(var(b))) # format
|
Vertex: FuncValue
|
||||||
Edge: var(b) -> call:len(var(b)) # 0
|
Vertex: FuncValue
|
||||||
Vertex: call:fmt.printf(str("len is: %d"), call:len(var(b)))
|
Vertex: call
|
||||||
Vertex: call:len(var(b))
|
Vertex: call
|
||||||
Vertex: int(-37)
|
Vertex: composite
|
||||||
Vertex: int(0)
|
Vertex: const
|
||||||
Vertex: int(13)
|
Vertex: const
|
||||||
Vertex: int(42)
|
Vertex: const
|
||||||
Vertex: list(int(13), int(42), int(0), int(-37))
|
Vertex: const
|
||||||
Vertex: str("len is: %d")
|
Vertex: const
|
||||||
Vertex: var(b)
|
|
||||||
|
|||||||
@@ -15,72 +15,51 @@ include foo(1)
|
|||||||
include foo(2)
|
include foo(2)
|
||||||
include foo(3)
|
include foo(3)
|
||||||
-- OUTPUT --
|
-- OUTPUT --
|
||||||
Edge: call:_operator(str("+"), call:_operator(str("+"), var(some_value1), var(some_value2)), int(4)) -> var(inside) # var:inside
|
Edge: FuncValue -> call # fn
|
||||||
Edge: call:_operator(str("+"), call:_operator(str("+"), var(some_value1), var(some_value2)), int(4)) -> var(inside) # var:inside
|
Edge: FuncValue -> call # fn
|
||||||
Edge: call:_operator(str("+"), call:_operator(str("+"), var(some_value1), var(some_value2)), int(4)) -> var(inside) # var:inside
|
Edge: FuncValue -> call # fn
|
||||||
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: FuncValue -> call # fn
|
||||||
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: FuncValue -> call # fn
|
||||||
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: FuncValue -> call # fn
|
||||||
Edge: int(1) -> var(num) # var:num
|
Edge: FuncValue -> call # fn
|
||||||
Edge: int(13) -> var(some_value2) # var:some_value2
|
Edge: FuncValue -> call # fn
|
||||||
Edge: int(13) -> var(some_value2) # var:some_value2
|
Edge: FuncValue -> call # fn
|
||||||
Edge: int(13) -> var(some_value2) # var:some_value2
|
Vertex: FuncValue
|
||||||
Edge: int(2) -> var(num) # var:num
|
Vertex: FuncValue
|
||||||
Edge: int(3) -> var(num) # var:num
|
Vertex: FuncValue
|
||||||
Edge: int(4) -> call:_operator(str("+"), call:_operator(str("+"), var(some_value1), var(some_value2)), int(4)) # b
|
Vertex: FuncValue
|
||||||
Edge: int(4) -> call:_operator(str("+"), call:_operator(str("+"), var(some_value1), var(some_value2)), int(4)) # b
|
Vertex: FuncValue
|
||||||
Edge: int(4) -> call:_operator(str("+"), call:_operator(str("+"), var(some_value1), var(some_value2)), int(4)) # b
|
Vertex: FuncValue
|
||||||
Edge: int(42) -> var(some_value1) # var:some_value1
|
Vertex: FuncValue
|
||||||
Edge: int(42) -> var(some_value1) # var:some_value1
|
Vertex: FuncValue
|
||||||
Edge: int(42) -> var(some_value1) # var:some_value1
|
Vertex: FuncValue
|
||||||
Edge: str("+") -> call:_operator(str("+"), call:_operator(str("+"), var(some_value1), var(some_value2)), int(4)) # op
|
Vertex: call
|
||||||
Edge: str("+") -> call:_operator(str("+"), call:_operator(str("+"), var(some_value1), var(some_value2)), int(4)) # op
|
Vertex: call
|
||||||
Edge: str("+") -> call:_operator(str("+"), call:_operator(str("+"), var(some_value1), var(some_value2)), int(4)) # op
|
Vertex: call
|
||||||
Edge: str("+") -> call:_operator(str("+"), var(some_value1), var(some_value2)) # op
|
Vertex: call
|
||||||
Edge: str("+") -> call:_operator(str("+"), var(some_value1), var(some_value2)) # op
|
Vertex: call
|
||||||
Edge: str("+") -> call:_operator(str("+"), var(some_value1), var(some_value2)) # op
|
Vertex: call
|
||||||
Edge: str("test-%d-%d") -> call:fmt.printf(str("test-%d-%d"), var(num), var(inside)) # format
|
Vertex: call
|
||||||
Edge: str("test-%d-%d") -> call:fmt.printf(str("test-%d-%d"), var(num), var(inside)) # format
|
Vertex: call
|
||||||
Edge: str("test-%d-%d") -> call:fmt.printf(str("test-%d-%d"), var(num), var(inside)) # format
|
Vertex: call
|
||||||
Edge: var(inside) -> call:fmt.printf(str("test-%d-%d"), var(num), var(inside)) # b
|
Vertex: const
|
||||||
Edge: var(inside) -> call:fmt.printf(str("test-%d-%d"), var(num), var(inside)) # b
|
Vertex: const
|
||||||
Edge: var(inside) -> call:fmt.printf(str("test-%d-%d"), var(num), var(inside)) # b
|
Vertex: const
|
||||||
Edge: var(num) -> call:fmt.printf(str("test-%d-%d"), var(num), var(inside)) # a
|
Vertex: const
|
||||||
Edge: var(num) -> call:fmt.printf(str("test-%d-%d"), var(num), var(inside)) # a
|
Vertex: const
|
||||||
Edge: var(num) -> call:fmt.printf(str("test-%d-%d"), var(num), var(inside)) # a
|
Vertex: const
|
||||||
Edge: var(some_value1) -> call:_operator(str("+"), var(some_value1), var(some_value2)) # a
|
Vertex: const
|
||||||
Edge: var(some_value1) -> call:_operator(str("+"), var(some_value1), var(some_value2)) # a
|
Vertex: const
|
||||||
Edge: var(some_value1) -> call:_operator(str("+"), var(some_value1), var(some_value2)) # a
|
Vertex: const
|
||||||
Edge: var(some_value2) -> call:_operator(str("+"), var(some_value1), var(some_value2)) # b
|
Vertex: const
|
||||||
Edge: var(some_value2) -> call:_operator(str("+"), var(some_value1), var(some_value2)) # b
|
Vertex: const
|
||||||
Edge: var(some_value2) -> call:_operator(str("+"), var(some_value1), var(some_value2)) # b
|
Vertex: const
|
||||||
Vertex: call:_operator(str("+"), call:_operator(str("+"), var(some_value1), var(some_value2)), int(4))
|
Vertex: const
|
||||||
Vertex: call:_operator(str("+"), call:_operator(str("+"), var(some_value1), var(some_value2)), int(4))
|
Vertex: const
|
||||||
Vertex: call:_operator(str("+"), call:_operator(str("+"), var(some_value1), var(some_value2)), int(4))
|
Vertex: const
|
||||||
Vertex: call:_operator(str("+"), var(some_value1), var(some_value2))
|
Vertex: const
|
||||||
Vertex: call:_operator(str("+"), var(some_value1), var(some_value2))
|
Vertex: const
|
||||||
Vertex: call:_operator(str("+"), var(some_value1), var(some_value2))
|
Vertex: const
|
||||||
Vertex: call:fmt.printf(str("test-%d-%d"), var(num), var(inside))
|
Vertex: const
|
||||||
Vertex: call:fmt.printf(str("test-%d-%d"), var(num), var(inside))
|
Vertex: const
|
||||||
Vertex: call:fmt.printf(str("test-%d-%d"), var(num), var(inside))
|
Vertex: const
|
||||||
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)
|
|
||||||
|
|||||||
@@ -8,14 +8,7 @@ class c1($a) {
|
|||||||
}
|
}
|
||||||
$foo = "hey"
|
$foo = "hey"
|
||||||
-- OUTPUT --
|
-- OUTPUT --
|
||||||
Edge: str("hey") -> var(foo) # var:foo
|
Vertex: const
|
||||||
Edge: str("hey") -> var(foo) # var:foo
|
Vertex: const
|
||||||
Edge: str("t1") -> var(a) # var:a
|
Vertex: const
|
||||||
Edge: str("t2") -> var(a) # var:a
|
Vertex: const
|
||||||
Vertex: str("hey")
|
|
||||||
Vertex: str("t1")
|
|
||||||
Vertex: str("t2")
|
|
||||||
Vertex: var(a)
|
|
||||||
Vertex: var(a)
|
|
||||||
Vertex: var(foo)
|
|
||||||
Vertex: var(foo)
|
|
||||||
|
|||||||
@@ -17,13 +17,14 @@ pkg "cowsay" {
|
|||||||
state => "newest",
|
state => "newest",
|
||||||
}
|
}
|
||||||
-- OUTPUT --
|
-- OUTPUT --
|
||||||
Edge: str("hello world") -> call:fmt.printf(str("hello world")) # format
|
Edge: FuncValue -> call # fn
|
||||||
Vertex: call:fmt.printf(str("hello world"))
|
Vertex: FuncValue
|
||||||
Vertex: str("/tmp/foo")
|
Vertex: call
|
||||||
Vertex: str("/tmp/foo")
|
Vertex: const
|
||||||
Vertex: str("cowsay")
|
Vertex: const
|
||||||
Vertex: str("cowsay")
|
Vertex: const
|
||||||
Vertex: str("hello world")
|
Vertex: const
|
||||||
Vertex: str("hello world")
|
Vertex: const
|
||||||
Vertex: str("installed")
|
Vertex: const
|
||||||
Vertex: str("newest")
|
Vertex: const
|
||||||
|
Vertex: const
|
||||||
|
|||||||
@@ -10,33 +10,11 @@ $out2 = $prefixer("b")
|
|||||||
test $out1 {} # helloa
|
test $out1 {} # helloa
|
||||||
test $out2 {} # hellob
|
test $out2 {} # hellob
|
||||||
-- OUTPUT --
|
-- OUTPUT --
|
||||||
Edge: call:_operator(str("+"), str("hello"), var(x)) -> func(x) { call:_operator(str("+"), str("hello"), var(x)) } # body
|
Edge: FuncValue -> call # fn
|
||||||
Edge: call:_operator(str("+"), str("hello"), var(x)) -> func(x) { call:_operator(str("+"), str("hello"), var(x)) } # body
|
Edge: FuncValue -> call # fn
|
||||||
Edge: call:prefixer(str("a")) -> var(out1) # var:out1
|
Vertex: FuncValue
|
||||||
Edge: call:prefixer(str("b")) -> var(out2) # var:out2
|
Vertex: FuncValue
|
||||||
Edge: func(x) { call:_operator(str("+"), str("hello"), var(x)) } -> call:prefixer(str("a")) # call:prefixer
|
Vertex: call
|
||||||
Edge: func(x) { call:_operator(str("+"), str("hello"), var(x)) } -> call:prefixer(str("b")) # call:prefixer
|
Vertex: call
|
||||||
Edge: str("+") -> call:_operator(str("+"), str("hello"), var(x)) # op
|
Vertex: const
|
||||||
Edge: str("+") -> call:_operator(str("+"), str("hello"), var(x)) # op
|
Vertex: const
|
||||||
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)
|
|
||||||
|
|||||||
@@ -9,14 +9,12 @@ test $names {}
|
|||||||
# multiples resources, defined by list
|
# multiples resources, defined by list
|
||||||
test ["hello", "world",] {}
|
test ["hello", "world",] {}
|
||||||
-- OUTPUT --
|
-- OUTPUT --
|
||||||
Edge: list(str("hey")) -> var(names) # var:names
|
Edge: const -> composite # 0
|
||||||
Edge: str("hello") -> list(str("hello"), str("world")) # 0
|
Edge: const -> composite # 0
|
||||||
Edge: str("hey") -> list(str("hey")) # 0
|
Edge: const -> composite # 1
|
||||||
Edge: str("world") -> list(str("hello"), str("world")) # 1
|
Vertex: composite
|
||||||
Vertex: list(str("hello"), str("world"))
|
Vertex: composite
|
||||||
Vertex: list(str("hey"))
|
Vertex: const
|
||||||
Vertex: str("hello")
|
Vertex: const
|
||||||
Vertex: str("hey")
|
Vertex: const
|
||||||
Vertex: str("name")
|
Vertex: const
|
||||||
Vertex: str("world")
|
|
||||||
Vertex: var(names)
|
|
||||||
|
|||||||
2
lang/interpret_test/TestAstFunc1/graph0.txtar
Normal file
2
lang/interpret_test/TestAstFunc1/graph0.txtar
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
-- main.mcl --
|
||||||
|
-- OUTPUT --
|
||||||
5
lang/interpret_test/TestAstFunc1/graph1.txtar
Normal file
5
lang/interpret_test/TestAstFunc1/graph1.txtar
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
-- main.mcl --
|
||||||
|
# TODO: this should fail with an unused variable error!
|
||||||
|
$x = 42
|
||||||
|
$y = $x
|
||||||
|
-- OUTPUT --
|
||||||
13
lang/interpret_test/TestAstFunc1/graph10.txtar
Normal file
13
lang/interpret_test/TestAstFunc1/graph10.txtar
Normal 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
|
||||||
14
lang/interpret_test/TestAstFunc1/graph11.txtar
Normal file
14
lang/interpret_test/TestAstFunc1/graph11.txtar
Normal 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
|
||||||
19
lang/interpret_test/TestAstFunc1/graph12.txtar
Normal file
19
lang/interpret_test/TestAstFunc1/graph12.txtar
Normal 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
|
||||||
14
lang/interpret_test/TestAstFunc1/graph13.txtar
Normal file
14
lang/interpret_test/TestAstFunc1/graph13.txtar
Normal 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
|
||||||
7
lang/interpret_test/TestAstFunc1/graph14.txtar
Normal file
7
lang/interpret_test/TestAstFunc1/graph14.txtar
Normal 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
|
||||||
6
lang/interpret_test/TestAstFunc1/graph2.txtar
Normal file
6
lang/interpret_test/TestAstFunc1/graph2.txtar
Normal 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
|
||||||
11
lang/interpret_test/TestAstFunc1/graph3.txtar
Normal file
11
lang/interpret_test/TestAstFunc1/graph3.txtar
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
-- main.mcl --
|
||||||
|
# chained vars
|
||||||
|
test "t" {
|
||||||
|
int64ptr => $c,
|
||||||
|
}
|
||||||
|
$c = $b
|
||||||
|
$b = $a
|
||||||
|
$a = 42
|
||||||
|
-- OUTPUT --
|
||||||
|
Vertex: const
|
||||||
|
Vertex: const
|
||||||
7
lang/interpret_test/TestAstFunc1/graph4.txtar
Normal file
7
lang/interpret_test/TestAstFunc1/graph4.txtar
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
-- main.mcl --
|
||||||
|
# simple bool
|
||||||
|
if $b {
|
||||||
|
}
|
||||||
|
$b = true
|
||||||
|
-- OUTPUT --
|
||||||
|
Vertex: const
|
||||||
13
lang/interpret_test/TestAstFunc1/graph5.txtar
Normal file
13
lang/interpret_test/TestAstFunc1/graph5.txtar
Normal 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
|
||||||
18
lang/interpret_test/TestAstFunc1/graph6.txtar
Normal file
18
lang/interpret_test/TestAstFunc1/graph6.txtar
Normal 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
|
||||||
18
lang/interpret_test/TestAstFunc1/graph7.txtar
Normal file
18
lang/interpret_test/TestAstFunc1/graph7.txtar
Normal 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
|
||||||
9
lang/interpret_test/TestAstFunc1/graph8.txtar
Normal file
9
lang/interpret_test/TestAstFunc1/graph8.txtar
Normal 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
|
||||||
6
lang/interpret_test/TestAstFunc1/graph9.txtar
Normal file
6
lang/interpret_test/TestAstFunc1/graph9.txtar
Normal 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
|
||||||
@@ -7,11 +7,9 @@ test "greeting" {
|
|||||||
anotherstr => fmt.printf("hello: %s", $s),
|
anotherstr => fmt.printf("hello: %s", $s),
|
||||||
}
|
}
|
||||||
-- OUTPUT --
|
-- OUTPUT --
|
||||||
Edge: str("hello: %s") -> call:fmt.printf(str("hello: %s"), var(s)) # format
|
Edge: FuncValue -> call # fn
|
||||||
Edge: str("world") -> var(s) # var:s
|
Vertex: FuncValue
|
||||||
Edge: var(s) -> call:fmt.printf(str("hello: %s"), var(s)) # a
|
Vertex: call
|
||||||
Vertex: call:fmt.printf(str("hello: %s"), var(s))
|
Vertex: const
|
||||||
Vertex: str("greeting")
|
Vertex: const
|
||||||
Vertex: str("hello: %s")
|
Vertex: const
|
||||||
Vertex: str("world")
|
|
||||||
Vertex: var(s)
|
|
||||||
|
|||||||
@@ -16,13 +16,13 @@ class xclass {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
-- OUTPUT --
|
-- OUTPUT --
|
||||||
Edge: call:os.is_debian() -> if( call:os.is_debian() ) { str("bbb") } else { str("ccc") } # c
|
Edge: FuncValue -> call # fn
|
||||||
Edge: if( call:os.is_debian() ) { str("bbb") } else { str("ccc") } -> var(aaa) # var:aaa
|
Edge: call -> if # c
|
||||||
Edge: str("bbb") -> if( call:os.is_debian() ) { str("bbb") } else { str("ccc") } # a
|
Edge: const -> if # a
|
||||||
Edge: str("ccc") -> if( call:os.is_debian() ) { str("bbb") } else { str("ccc") } # b
|
Edge: const -> if # b
|
||||||
Vertex: call:os.is_debian()
|
Vertex: FuncValue
|
||||||
Vertex: if( call:os.is_debian() ) { str("bbb") } else { str("ccc") }
|
Vertex: call
|
||||||
Vertex: str("bbb")
|
Vertex: const
|
||||||
Vertex: str("ccc")
|
Vertex: const
|
||||||
Vertex: str("hello")
|
Vertex: const
|
||||||
Vertex: var(aaa)
|
Vertex: if
|
||||||
|
|||||||
@@ -16,4 +16,4 @@ class xclass {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
-- OUTPUT --
|
-- 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
|
||||||
|
|||||||
@@ -15,13 +15,13 @@ class xclass {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
-- OUTPUT --
|
-- OUTPUT --
|
||||||
Edge: call:os.is_debian() -> if( call:os.is_debian() ) { str("bbb") } else { str("ccc") } # c
|
Edge: FuncValue -> call # fn
|
||||||
Edge: if( call:os.is_debian() ) { str("bbb") } else { str("ccc") } -> var(aaa) # var:aaa
|
Edge: call -> if # c
|
||||||
Edge: str("bbb") -> if( call:os.is_debian() ) { str("bbb") } else { str("ccc") } # a
|
Edge: const -> if # a
|
||||||
Edge: str("ccc") -> if( call:os.is_debian() ) { str("bbb") } else { str("ccc") } # b
|
Edge: const -> if # b
|
||||||
Vertex: call:os.is_debian()
|
Vertex: FuncValue
|
||||||
Vertex: if( call:os.is_debian() ) { str("bbb") } else { str("ccc") }
|
Vertex: call
|
||||||
Vertex: str("bbb")
|
Vertex: const
|
||||||
Vertex: str("ccc")
|
Vertex: const
|
||||||
Vertex: str("hello")
|
Vertex: const
|
||||||
Vertex: var(aaa)
|
Vertex: if
|
||||||
|
|||||||
@@ -12,48 +12,14 @@ $out2 = $prefixer($out1)
|
|||||||
test $out1 {}
|
test $out1 {}
|
||||||
test $out2 {}
|
test $out2 {}
|
||||||
-- OUTPUT --
|
-- 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: FuncValue -> call # fn
|
||||||
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: FuncValue -> call # fn
|
||||||
Edge: call:_operator(str("+"), var(prefix), str(":")) -> call:_operator(str("+"), call:_operator(str("+"), var(prefix), str(":")), var(x)) # a
|
Edge: FuncValue -> call # fn
|
||||||
Edge: call:_operator(str("+"), var(prefix), str(":")) -> call:_operator(str("+"), call:_operator(str("+"), var(prefix), str(":")), var(x)) # a
|
Vertex: FuncValue
|
||||||
Edge: call:prefixer(str("world")) -> var(out1) # var:out1
|
Vertex: FuncValue
|
||||||
Edge: call:prefixer(str("world")) -> var(out1) # var:out1
|
Vertex: FuncValue
|
||||||
Edge: call:prefixer(var(out1)) -> var(out2) # var:out2
|
Vertex: call
|
||||||
Edge: func(x) { call:_operator(str("+"), call:_operator(str("+"), var(prefix), str(":")), var(x)) } -> call:prefixer(str("world")) # call:prefixer
|
Vertex: call
|
||||||
Edge: func(x) { call:_operator(str("+"), call:_operator(str("+"), var(prefix), str(":")), var(x)) } -> call:prefixer(var(out1)) # call:prefixer
|
Vertex: call
|
||||||
Edge: str("+") -> call:_operator(str("+"), call:_operator(str("+"), var(prefix), str(":")), var(x)) # op
|
Vertex: const
|
||||||
Edge: str("+") -> call:_operator(str("+"), call:_operator(str("+"), var(prefix), str(":")), var(x)) # op
|
Vertex: const
|
||||||
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)
|
|
||||||
|
|||||||
@@ -62,67 +62,42 @@ $ex1 = $example1.name
|
|||||||
|
|
||||||
$name = "i am github.com/purpleidea/mgmt-example2/ and i contain: " + $ex1
|
$name = "i am github.com/purpleidea/mgmt-example2/ and i contain: " + $ex1
|
||||||
-- OUTPUT --
|
-- OUTPUT --
|
||||||
Edge: call:_operator(str("+"), int(42), var(third.three)) -> var(h2g2.answer) # var:h2g2.answer
|
Edge: FuncValue -> call # fn
|
||||||
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: FuncValue -> call # fn
|
||||||
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: FuncValue -> call # fn
|
||||||
Edge: call:_operator(str("+"), str("this is module mod1 which contains: "), var(mod1.name)) -> var(mod1.name) # var:mod1.name
|
Edge: FuncValue -> call # fn
|
||||||
Edge: int(3) -> var(third.three) # var:third.three
|
Edge: FuncValue -> call # fn
|
||||||
Edge: int(42) -> call:_operator(str("+"), int(42), var(third.three)) # a
|
Edge: FuncValue -> call # fn
|
||||||
Edge: str("+") -> call:_operator(str("+"), int(42), var(third.three)) # op
|
Edge: FuncValue -> call # fn
|
||||||
Edge: str("+") -> call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) # op
|
Vertex: FuncValue
|
||||||
Edge: str("+") -> call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) # op
|
Vertex: FuncValue
|
||||||
Edge: str("+") -> call:_operator(str("+"), str("this is module mod1 which contains: "), var(mod1.name)) # op
|
Vertex: FuncValue
|
||||||
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
|
Vertex: FuncValue
|
||||||
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
|
Vertex: FuncValue
|
||||||
Edge: str("i imported local: %s") -> call:fmt.printf(str("i imported local: %s"), var(mod1.name)) # format
|
Vertex: FuncValue
|
||||||
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
|
Vertex: FuncValue
|
||||||
Edge: str("the answer is: %d") -> call:fmt.printf(str("the answer is: %d"), var(answer)) # format
|
Vertex: call
|
||||||
Edge: str("this is module mod1 which contains: ") -> call:_operator(str("+"), str("this is module mod1 which contains: "), var(mod1.name)) # a
|
Vertex: call
|
||||||
Edge: str("this is the nested git module mod1") -> var(mod1.name) # var:mod1.name
|
Vertex: call
|
||||||
Edge: str("this is the nested git module mod1") -> var(mod1.name) # var:mod1.name
|
Vertex: call
|
||||||
Edge: str("this is the nested local module mod1") -> var(mod1.name) # var:mod1.name
|
Vertex: call
|
||||||
Edge: var(answer) -> call:fmt.printf(str("the answer is: %d"), var(answer)) # a
|
Vertex: call
|
||||||
Edge: var(example1.name) -> call:fmt.printf(str("i imported remote: %s and %s"), var(example1.name), var(example2.ex1)) # a
|
Vertex: call
|
||||||
Edge: var(example1.name) -> var(example2.ex1) # var:example2.ex1
|
Vertex: const
|
||||||
Edge: var(example2.ex1) -> call:fmt.printf(str("i imported remote: %s and %s"), var(example1.name), var(example2.ex1)) # b
|
Vertex: const
|
||||||
Edge: var(h2g2.answer) -> var(answer) # var:answer
|
Vertex: const
|
||||||
Edge: var(mod1.name) -> call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) # b
|
Vertex: const
|
||||||
Edge: var(mod1.name) -> call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) # b
|
Vertex: const
|
||||||
Edge: var(mod1.name) -> call:_operator(str("+"), str("this is module mod1 which contains: "), var(mod1.name)) # b
|
Vertex: const
|
||||||
Edge: var(mod1.name) -> call:fmt.printf(str("i imported local: %s"), var(mod1.name)) # a
|
Vertex: const
|
||||||
Edge: var(third.three) -> call:_operator(str("+"), int(42), var(third.three)) # b
|
Vertex: const
|
||||||
Vertex: call:_operator(str("+"), int(42), var(third.three))
|
Vertex: const
|
||||||
Vertex: call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name))
|
Vertex: const
|
||||||
Vertex: call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name))
|
Vertex: const
|
||||||
Vertex: call:_operator(str("+"), str("this is module mod1 which contains: "), var(mod1.name))
|
Vertex: const
|
||||||
Vertex: call:fmt.printf(str("i imported local: %s"), var(mod1.name))
|
Vertex: const
|
||||||
Vertex: call:fmt.printf(str("i imported remote: %s and %s"), var(example1.name), var(example2.ex1))
|
Vertex: const
|
||||||
Vertex: call:fmt.printf(str("the answer is: %d"), var(answer))
|
Vertex: const
|
||||||
Vertex: int(3)
|
Vertex: const
|
||||||
Vertex: int(42)
|
Vertex: const
|
||||||
Vertex: str("+")
|
Vertex: const
|
||||||
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)
|
|
||||||
|
|||||||
@@ -10,34 +10,29 @@ class c1($a, $b) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
-- OUTPUT --
|
-- OUTPUT --
|
||||||
Edge: call:len(var(b)) -> call:fmt.printf(str("len is: %d"), call:len(var(b))) # a
|
Edge: FuncValue -> call # fn
|
||||||
Edge: call:len(var(b)) -> call:fmt.printf(str("len is: %d"), call:len(var(b))) # a
|
Edge: FuncValue -> call # fn
|
||||||
Edge: int(-37) -> list(int(13), int(42), int(0), int(-37)) # 3
|
Edge: FuncValue -> call # fn
|
||||||
Edge: int(0) -> list(int(13), int(42), int(0), int(-37)) # 2
|
Edge: FuncValue -> call # fn
|
||||||
Edge: int(13) -> list(int(13), int(42), int(0), int(-37)) # 0
|
Edge: const -> composite # 0
|
||||||
Edge: int(42) -> list(int(13), int(42), int(0), int(-37)) # 1
|
Edge: const -> composite # 1
|
||||||
Edge: list(int(13), int(42), int(0), int(-37)) -> var(b) # var:b
|
Edge: const -> composite # 2
|
||||||
Edge: str("hello") -> var(b) # var:b
|
Edge: const -> composite # 3
|
||||||
Edge: str("len is: %d") -> call:fmt.printf(str("len is: %d"), call:len(var(b))) # format
|
Vertex: FuncValue
|
||||||
Edge: str("len is: %d") -> call:fmt.printf(str("len is: %d"), call:len(var(b))) # format
|
Vertex: FuncValue
|
||||||
Edge: str("t1") -> var(a) # var:a
|
Vertex: FuncValue
|
||||||
Edge: str("t2") -> var(a) # var:a
|
Vertex: FuncValue
|
||||||
Edge: var(b) -> call:len(var(b)) # 0
|
Vertex: call
|
||||||
Edge: var(b) -> call:len(var(b)) # 0
|
Vertex: call
|
||||||
Vertex: call:fmt.printf(str("len is: %d"), call:len(var(b)))
|
Vertex: call
|
||||||
Vertex: call:fmt.printf(str("len is: %d"), call:len(var(b)))
|
Vertex: call
|
||||||
Vertex: call:len(var(b))
|
Vertex: composite
|
||||||
Vertex: call:len(var(b))
|
Vertex: const
|
||||||
Vertex: int(-37)
|
Vertex: const
|
||||||
Vertex: int(0)
|
Vertex: const
|
||||||
Vertex: int(13)
|
Vertex: const
|
||||||
Vertex: int(42)
|
Vertex: const
|
||||||
Vertex: list(int(13), int(42), int(0), int(-37))
|
Vertex: const
|
||||||
Vertex: str("hello")
|
Vertex: const
|
||||||
Vertex: str("len is: %d")
|
Vertex: const
|
||||||
Vertex: str("t1")
|
Vertex: const
|
||||||
Vertex: str("t2")
|
|
||||||
Vertex: var(a)
|
|
||||||
Vertex: var(a)
|
|
||||||
Vertex: var(b)
|
|
||||||
Vertex: var(b)
|
|
||||||
|
|||||||
@@ -60,67 +60,42 @@ $ex1 = $example1.name
|
|||||||
|
|
||||||
$name = "i am github.com/purpleidea/mgmt-example2/ and i contain: " + $ex1
|
$name = "i am github.com/purpleidea/mgmt-example2/ and i contain: " + $ex1
|
||||||
-- OUTPUT --
|
-- OUTPUT --
|
||||||
Edge: call:_operator(str("+"), int(42), var(third.three)) -> var(h2g2.answer) # var:h2g2.answer
|
Edge: FuncValue -> call # fn
|
||||||
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: FuncValue -> call # fn
|
||||||
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: FuncValue -> call # fn
|
||||||
Edge: call:_operator(str("+"), str("this is module mod1 which contains: "), var(mod1.name)) -> var(mod1.name) # var:mod1.name
|
Edge: FuncValue -> call # fn
|
||||||
Edge: int(3) -> var(third.three) # var:third.three
|
Edge: FuncValue -> call # fn
|
||||||
Edge: int(42) -> call:_operator(str("+"), int(42), var(third.three)) # a
|
Edge: FuncValue -> call # fn
|
||||||
Edge: str("+") -> call:_operator(str("+"), int(42), var(third.three)) # op
|
Edge: FuncValue -> call # fn
|
||||||
Edge: str("+") -> call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) # op
|
Vertex: FuncValue
|
||||||
Edge: str("+") -> call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) # op
|
Vertex: FuncValue
|
||||||
Edge: str("+") -> call:_operator(str("+"), str("this is module mod1 which contains: "), var(mod1.name)) # op
|
Vertex: FuncValue
|
||||||
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
|
Vertex: FuncValue
|
||||||
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
|
Vertex: FuncValue
|
||||||
Edge: str("i imported local: %s") -> call:fmt.printf(str("i imported local: %s"), var(mod1.name)) # format
|
Vertex: FuncValue
|
||||||
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
|
Vertex: FuncValue
|
||||||
Edge: str("the answer is: %d") -> call:fmt.printf(str("the answer is: %d"), var(answer)) # format
|
Vertex: call
|
||||||
Edge: str("this is module mod1 which contains: ") -> call:_operator(str("+"), str("this is module mod1 which contains: "), var(mod1.name)) # a
|
Vertex: call
|
||||||
Edge: str("this is the nested git module mod1") -> var(mod1.name) # var:mod1.name
|
Vertex: call
|
||||||
Edge: str("this is the nested git module mod1") -> var(mod1.name) # var:mod1.name
|
Vertex: call
|
||||||
Edge: str("this is the nested local module mod1") -> var(mod1.name) # var:mod1.name
|
Vertex: call
|
||||||
Edge: var(answer) -> call:fmt.printf(str("the answer is: %d"), var(answer)) # a
|
Vertex: call
|
||||||
Edge: var(example1.name) -> call:fmt.printf(str("i imported remote: %s and %s"), var(example1.name), var(example2.ex1)) # a
|
Vertex: call
|
||||||
Edge: var(example1.name) -> var(example2.ex1) # var:example2.ex1
|
Vertex: const
|
||||||
Edge: var(example2.ex1) -> call:fmt.printf(str("i imported remote: %s and %s"), var(example1.name), var(example2.ex1)) # b
|
Vertex: const
|
||||||
Edge: var(h2g2.answer) -> var(answer) # var:answer
|
Vertex: const
|
||||||
Edge: var(mod1.name) -> call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) # b
|
Vertex: const
|
||||||
Edge: var(mod1.name) -> call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name)) # b
|
Vertex: const
|
||||||
Edge: var(mod1.name) -> call:_operator(str("+"), str("this is module mod1 which contains: "), var(mod1.name)) # b
|
Vertex: const
|
||||||
Edge: var(mod1.name) -> call:fmt.printf(str("i imported local: %s"), var(mod1.name)) # a
|
Vertex: const
|
||||||
Edge: var(third.three) -> call:_operator(str("+"), int(42), var(third.three)) # b
|
Vertex: const
|
||||||
Vertex: call:_operator(str("+"), int(42), var(third.three))
|
Vertex: const
|
||||||
Vertex: call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name))
|
Vertex: const
|
||||||
Vertex: call:_operator(str("+"), str("i am github.com/purpleidea/mgmt-example1/ and i contain: "), var(mod1.name))
|
Vertex: const
|
||||||
Vertex: call:_operator(str("+"), str("this is module mod1 which contains: "), var(mod1.name))
|
Vertex: const
|
||||||
Vertex: call:fmt.printf(str("i imported local: %s"), var(mod1.name))
|
Vertex: const
|
||||||
Vertex: call:fmt.printf(str("i imported remote: %s and %s"), var(example1.name), var(example2.ex1))
|
Vertex: const
|
||||||
Vertex: call:fmt.printf(str("the answer is: %d"), var(answer))
|
Vertex: const
|
||||||
Vertex: int(3)
|
Vertex: const
|
||||||
Vertex: int(42)
|
Vertex: const
|
||||||
Vertex: str("+")
|
Vertex: const
|
||||||
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)
|
|
||||||
|
|||||||
@@ -1,24 +1,62 @@
|
|||||||
-- main.mcl --
|
-- main.mcl --
|
||||||
|
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
|
# 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{
|
#Meta => true ?: struct{
|
||||||
# noop => false,
|
# noop => false,
|
||||||
#},
|
#},
|
||||||
#}
|
}
|
||||||
-- OUTPUT --
|
-- 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
|
||||||
|
|||||||
@@ -11,14 +11,8 @@ $out = $fn()
|
|||||||
|
|
||||||
test $out {}
|
test $out {}
|
||||||
-- OUTPUT --
|
-- OUTPUT --
|
||||||
Edge: call:fn() -> var(out) # var:out
|
Edge: FuncValue -> call # fn
|
||||||
Edge: call:funcgen() -> call:fn() # call:fn
|
Edge: call -> call # fn
|
||||||
Edge: func() { func() { str("hello") } } -> call:funcgen() # call:funcgen
|
Vertex: FuncValue
|
||||||
Edge: func() { str("hello") } -> func() { func() { str("hello") } } # body
|
Vertex: call
|
||||||
Edge: str("hello") -> func() { str("hello") } # body
|
Vertex: call
|
||||||
Vertex: call:fn()
|
|
||||||
Vertex: call:funcgen()
|
|
||||||
Vertex: func() { func() { str("hello") } }
|
|
||||||
Vertex: func() { str("hello") }
|
|
||||||
Vertex: str("hello")
|
|
||||||
Vertex: var(out)
|
|
||||||
|
|||||||
@@ -10,14 +10,8 @@ $out = $fn()
|
|||||||
|
|
||||||
test $out {}
|
test $out {}
|
||||||
-- OUTPUT --
|
-- OUTPUT --
|
||||||
Edge: call:fn() -> var(out) # var:out
|
Edge: FuncValue -> call # fn
|
||||||
Edge: call:funcgen() -> call:fn() # call:fn
|
Edge: call -> call # fn
|
||||||
Edge: func() { func() { str("hello") } } -> call:funcgen() # call:funcgen
|
Vertex: FuncValue
|
||||||
Edge: func() { str("hello") } -> func() { func() { str("hello") } } # body
|
Vertex: call
|
||||||
Edge: str("hello") -> func() { str("hello") } # body
|
Vertex: call
|
||||||
Vertex: call:fn()
|
|
||||||
Vertex: call:funcgen()
|
|
||||||
Vertex: func() { func() { str("hello") } }
|
|
||||||
Vertex: func() { str("hello") }
|
|
||||||
Vertex: str("hello")
|
|
||||||
Vertex: var(out)
|
|
||||||
|
|||||||
@@ -6,7 +6,5 @@ if true {
|
|||||||
}
|
}
|
||||||
test $x {}
|
test $x {}
|
||||||
-- OUTPUT --
|
-- OUTPUT --
|
||||||
Edge: str("hello") -> var(x) # var:x
|
Vertex: const
|
||||||
Vertex: bool(true)
|
Vertex: const
|
||||||
Vertex: str("hello")
|
|
||||||
Vertex: var(x)
|
|
||||||
|
|||||||
@@ -6,7 +6,5 @@ if true {
|
|||||||
test $x {}
|
test $x {}
|
||||||
}
|
}
|
||||||
-- OUTPUT --
|
-- OUTPUT --
|
||||||
Edge: str("world") -> var(x) # var:x
|
Vertex: const
|
||||||
Vertex: bool(true)
|
Vertex: const
|
||||||
Vertex: str("world")
|
|
||||||
Vertex: var(x)
|
|
||||||
|
|||||||
@@ -7,10 +7,6 @@ $out1 = answer()
|
|||||||
|
|
||||||
test $out1 {}
|
test $out1 {}
|
||||||
-- OUTPUT --
|
-- OUTPUT --
|
||||||
Edge: call:answer() -> var(out1) # var:out1
|
Edge: FuncValue -> call # fn
|
||||||
Edge: func() { str("the answer is 42") } -> call:answer() # call:answer
|
Vertex: FuncValue
|
||||||
Edge: str("the answer is 42") -> func() { str("the answer is 42") } # body
|
Vertex: call
|
||||||
Vertex: call:answer()
|
|
||||||
Vertex: func() { str("the answer is 42") }
|
|
||||||
Vertex: str("the answer is 42")
|
|
||||||
Vertex: var(out1)
|
|
||||||
|
|||||||
@@ -8,19 +8,13 @@ $out2 = answer()
|
|||||||
|
|
||||||
test $out1 + $out2 {}
|
test $out1 + $out2 {}
|
||||||
-- OUTPUT --
|
-- OUTPUT --
|
||||||
Edge: call:answer() -> var(out1) # var:out1
|
Edge: FuncValue -> call # fn
|
||||||
Edge: call:answer() -> var(out2) # var:out2
|
Edge: FuncValue -> call # fn
|
||||||
Edge: func() { str("the answer is 42") } -> call:answer() # call:answer
|
Edge: FuncValue -> call # fn
|
||||||
Edge: func() { str("the answer is 42") } -> call:answer() # call:answer
|
Vertex: FuncValue
|
||||||
Edge: str("+") -> call:_operator(str("+"), var(out1), var(out2)) # op
|
Vertex: FuncValue
|
||||||
Edge: str("the answer is 42") -> func() { str("the answer is 42") } # body
|
Vertex: FuncValue
|
||||||
Edge: var(out1) -> call:_operator(str("+"), var(out1), var(out2)) # a
|
Vertex: call
|
||||||
Edge: var(out2) -> call:_operator(str("+"), var(out1), var(out2)) # b
|
Vertex: call
|
||||||
Vertex: call:_operator(str("+"), var(out1), var(out2))
|
Vertex: call
|
||||||
Vertex: call:answer()
|
Vertex: const
|
||||||
Vertex: call:answer()
|
|
||||||
Vertex: func() { str("the answer is 42") }
|
|
||||||
Vertex: str("+")
|
|
||||||
Vertex: str("the answer is 42")
|
|
||||||
Vertex: var(out1)
|
|
||||||
Vertex: var(out2)
|
|
||||||
|
|||||||
@@ -10,10 +10,6 @@ $out = $answer()
|
|||||||
|
|
||||||
test $out {}
|
test $out {}
|
||||||
-- OUTPUT --
|
-- OUTPUT --
|
||||||
Edge: call:answer() -> var(out) # var:out
|
Edge: FuncValue -> call # fn
|
||||||
Edge: func() { str("the answer is 42") } -> call:answer() # call:answer
|
Vertex: FuncValue
|
||||||
Edge: str("the answer is 42") -> func() { str("the answer is 42") } # body
|
Vertex: call
|
||||||
Vertex: call:answer()
|
|
||||||
Vertex: func() { str("the answer is 42") }
|
|
||||||
Vertex: str("the answer is 42")
|
|
||||||
Vertex: var(out)
|
|
||||||
|
|||||||
@@ -11,19 +11,13 @@ $out2 = $answer()
|
|||||||
|
|
||||||
test $out1 + $out2 {}
|
test $out1 + $out2 {}
|
||||||
-- OUTPUT --
|
-- OUTPUT --
|
||||||
Edge: call:answer() -> var(out1) # var:out1
|
Edge: FuncValue -> call # fn
|
||||||
Edge: call:answer() -> var(out2) # var:out2
|
Edge: FuncValue -> call # fn
|
||||||
Edge: func() { str("the answer is 42") } -> call:answer() # call:answer
|
Edge: FuncValue -> call # fn
|
||||||
Edge: func() { str("the answer is 42") } -> call:answer() # call:answer
|
Vertex: FuncValue
|
||||||
Edge: str("+") -> call:_operator(str("+"), var(out1), var(out2)) # op
|
Vertex: FuncValue
|
||||||
Edge: str("the answer is 42") -> func() { str("the answer is 42") } # body
|
Vertex: FuncValue
|
||||||
Edge: var(out1) -> call:_operator(str("+"), var(out1), var(out2)) # a
|
Vertex: call
|
||||||
Edge: var(out2) -> call:_operator(str("+"), var(out1), var(out2)) # b
|
Vertex: call
|
||||||
Vertex: call:_operator(str("+"), var(out1), var(out2))
|
Vertex: call
|
||||||
Vertex: call:answer()
|
Vertex: const
|
||||||
Vertex: call:answer()
|
|
||||||
Vertex: func() { str("the answer is 42") }
|
|
||||||
Vertex: str("+")
|
|
||||||
Vertex: str("the answer is 42")
|
|
||||||
Vertex: var(out1)
|
|
||||||
Vertex: var(out2)
|
|
||||||
|
|||||||
@@ -52,91 +52,90 @@ if $state == "three" {
|
|||||||
Exec["timer"] -> Kv["${ns}"]
|
Exec["timer"] -> Kv["${ns}"]
|
||||||
}
|
}
|
||||||
-- OUTPUT --
|
-- 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: FuncValue -> call # fn
|
||||||
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: FuncValue -> call # fn
|
||||||
Edge: call:maplookup(var(exchanged), var(hostname), str("default")) -> var(state) # var:state
|
Edge: FuncValue -> call # fn
|
||||||
Edge: call:maplookup(var(exchanged), var(hostname), str("default")) -> var(state) # var:state
|
Edge: FuncValue -> call # fn
|
||||||
Edge: call:maplookup(var(exchanged), var(hostname), str("default")) -> var(state) # var:state
|
Edge: FuncValue -> call # fn
|
||||||
Edge: call:maplookup(var(exchanged), var(hostname), str("default")) -> var(state) # var:state
|
Edge: FuncValue -> call # fn
|
||||||
Edge: call:world.kvlookup(var(ns)) -> var(exchanged) # var:exchanged
|
Edge: FuncValue -> call # fn
|
||||||
Edge: str("") -> var(hostname) # var:hostname
|
Edge: FuncValue -> call # fn
|
||||||
Edge: str("==") -> call:_operator(str("=="), var(state), str("default")) # op
|
Edge: FuncValue -> call # fn
|
||||||
Edge: str("==") -> call:_operator(str("=="), var(state), str("one")) # op
|
Edge: FuncValue -> call # fn
|
||||||
Edge: str("==") -> call:_operator(str("=="), var(state), str("three")) # op
|
Edge: FuncValue -> call # fn
|
||||||
Edge: str("==") -> call:_operator(str("=="), var(state), str("two")) # op
|
Edge: FuncValue -> call # fn
|
||||||
Edge: str("default") -> call:_operator(str("=="), var(state), str("default")) # b
|
Edge: FuncValue -> call # fn
|
||||||
Edge: str("default") -> call:maplookup(var(exchanged), var(hostname), str("default")) # default
|
Vertex: FuncValue
|
||||||
Edge: str("estate") -> var(ns) # var:ns
|
Vertex: FuncValue
|
||||||
Edge: str("estate") -> var(ns) # var:ns
|
Vertex: FuncValue
|
||||||
Edge: str("estate") -> var(ns) # var:ns
|
Vertex: FuncValue
|
||||||
Edge: str("estate") -> var(ns) # var:ns
|
Vertex: FuncValue
|
||||||
Edge: str("estate") -> var(ns) # var:ns
|
Vertex: FuncValue
|
||||||
Edge: str("estate") -> var(ns) # var:ns
|
Vertex: FuncValue
|
||||||
Edge: str("estate") -> var(ns) # var:ns
|
Vertex: FuncValue
|
||||||
Edge: str("estate") -> var(ns) # var:ns
|
Vertex: FuncValue
|
||||||
Edge: str("estate") -> var(ns) # var:ns
|
Vertex: FuncValue
|
||||||
Edge: str("estate") -> var(ns) # var:ns
|
Vertex: FuncValue
|
||||||
Edge: str("one") -> call:_operator(str("=="), var(state), str("one")) # b
|
Vertex: FuncValue
|
||||||
Edge: str("three") -> call:_operator(str("=="), var(state), str("three")) # b
|
Vertex: FuncValue
|
||||||
Edge: str("two") -> call:_operator(str("=="), var(state), str("two")) # b
|
Vertex: call
|
||||||
Edge: str("||") -> call:_operator(str("||"), call:_operator(str("=="), var(state), str("one")), call:_operator(str("=="), var(state), str("default"))) # op
|
Vertex: call
|
||||||
Edge: var(exchanged) -> call:maplookup(var(exchanged), var(hostname), str("default")) # map
|
Vertex: call
|
||||||
Edge: var(hostname) -> call:maplookup(var(exchanged), var(hostname), str("default")) # key
|
Vertex: call
|
||||||
Edge: var(ns) -> call:world.kvlookup(var(ns)) # namespace
|
Vertex: call
|
||||||
Edge: var(state) -> call:_operator(str("=="), var(state), str("default")) # a
|
Vertex: call
|
||||||
Edge: var(state) -> call:_operator(str("=="), var(state), str("one")) # a
|
Vertex: call
|
||||||
Edge: var(state) -> call:_operator(str("=="), var(state), str("three")) # a
|
Vertex: call
|
||||||
Edge: var(state) -> call:_operator(str("=="), var(state), str("two")) # a
|
Vertex: call
|
||||||
Vertex: call:_operator(str("=="), var(state), str("default"))
|
Vertex: call
|
||||||
Vertex: call:_operator(str("=="), var(state), str("one"))
|
Vertex: call
|
||||||
Vertex: call:_operator(str("=="), var(state), str("three"))
|
Vertex: call
|
||||||
Vertex: call:_operator(str("=="), var(state), str("two"))
|
Vertex: call
|
||||||
Vertex: call:_operator(str("||"), call:_operator(str("=="), var(state), str("one")), call:_operator(str("=="), var(state), str("default")))
|
Vertex: const
|
||||||
Vertex: call:maplookup(var(exchanged), var(hostname), str("default"))
|
Vertex: const
|
||||||
Vertex: call:world.kvlookup(var(ns))
|
Vertex: const
|
||||||
Vertex: str("")
|
Vertex: const
|
||||||
Vertex: str("/tmp/mgmt/state")
|
Vertex: const
|
||||||
Vertex: str("/tmp/mgmt/state")
|
Vertex: const
|
||||||
Vertex: str("/tmp/mgmt/state")
|
Vertex: const
|
||||||
Vertex: str("/usr/bin/sleep 1s")
|
Vertex: const
|
||||||
Vertex: str("/usr/bin/sleep 1s")
|
Vertex: const
|
||||||
Vertex: str("/usr/bin/sleep 1s")
|
Vertex: const
|
||||||
Vertex: str("==")
|
Vertex: const
|
||||||
Vertex: str("==")
|
Vertex: const
|
||||||
Vertex: str("==")
|
Vertex: const
|
||||||
Vertex: str("==")
|
Vertex: const
|
||||||
Vertex: str("default")
|
Vertex: const
|
||||||
Vertex: str("default")
|
Vertex: const
|
||||||
Vertex: str("estate")
|
Vertex: const
|
||||||
Vertex: str("one")
|
Vertex: const
|
||||||
Vertex: str("one")
|
Vertex: const
|
||||||
Vertex: str("state: one\n")
|
Vertex: const
|
||||||
Vertex: str("state: three\n")
|
Vertex: const
|
||||||
Vertex: str("state: two\n")
|
Vertex: const
|
||||||
Vertex: str("three")
|
Vertex: const
|
||||||
Vertex: str("three")
|
Vertex: const
|
||||||
Vertex: str("timer")
|
Vertex: const
|
||||||
Vertex: str("timer")
|
Vertex: const
|
||||||
Vertex: str("timer")
|
Vertex: const
|
||||||
Vertex: str("timer")
|
Vertex: const
|
||||||
Vertex: str("timer")
|
Vertex: const
|
||||||
Vertex: str("timer")
|
Vertex: const
|
||||||
Vertex: str("two")
|
Vertex: const
|
||||||
Vertex: str("two")
|
Vertex: const
|
||||||
Vertex: str("||")
|
Vertex: const
|
||||||
Vertex: var(exchanged)
|
Vertex: const
|
||||||
Vertex: var(hostname)
|
Vertex: const
|
||||||
Vertex: var(ns)
|
Vertex: const
|
||||||
Vertex: var(ns)
|
Vertex: const
|
||||||
Vertex: var(ns)
|
Vertex: const
|
||||||
Vertex: var(ns)
|
Vertex: const
|
||||||
Vertex: var(ns)
|
Vertex: const
|
||||||
Vertex: var(ns)
|
Vertex: const
|
||||||
Vertex: var(ns)
|
Vertex: const
|
||||||
Vertex: var(ns)
|
Vertex: const
|
||||||
Vertex: var(ns)
|
Vertex: const
|
||||||
Vertex: var(ns)
|
Vertex: const
|
||||||
Vertex: var(state)
|
Vertex: const
|
||||||
Vertex: var(state)
|
Vertex: const
|
||||||
Vertex: var(state)
|
Vertex: const
|
||||||
Vertex: var(state)
|
|
||||||
|
|||||||
@@ -16,15 +16,15 @@ test "greeting3" {
|
|||||||
anotherstr => $fn(),
|
anotherstr => $fn(),
|
||||||
}
|
}
|
||||||
-- OUTPUT --
|
-- OUTPUT --
|
||||||
Edge: func() { str("hello world") } -> call:fn() # call:fn
|
Edge: FuncValue -> call # fn
|
||||||
Edge: func() { str("hello world") } -> call:fn() # call:fn
|
Edge: FuncValue -> call # fn
|
||||||
Edge: func() { str("hello world") } -> call:fn() # call:fn
|
Edge: FuncValue -> call # fn
|
||||||
Edge: str("hello world") -> func() { str("hello world") } # body
|
Vertex: FuncValue
|
||||||
Vertex: call:fn()
|
Vertex: FuncValue
|
||||||
Vertex: call:fn()
|
Vertex: FuncValue
|
||||||
Vertex: call:fn()
|
Vertex: call
|
||||||
Vertex: func() { str("hello world") }
|
Vertex: call
|
||||||
Vertex: str("greeting1")
|
Vertex: call
|
||||||
Vertex: str("greeting2")
|
Vertex: const
|
||||||
Vertex: str("greeting3")
|
Vertex: const
|
||||||
Vertex: str("hello world")
|
Vertex: const
|
||||||
|
|||||||
@@ -18,59 +18,15 @@ test "greeting3" {
|
|||||||
anotherstr => $fn(),
|
anotherstr => $fn(),
|
||||||
}
|
}
|
||||||
-- OUTPUT --
|
-- 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: FuncValue -> call # fn
|
||||||
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: FuncValue -> call # fn
|
||||||
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: FuncValue -> call # fn
|
||||||
Edge: call:_operator(str("+"), var(s1), str(" ")) -> call:_operator(str("+"), call:_operator(str("+"), var(s1), str(" ")), var(s2)) # a
|
Vertex: FuncValue
|
||||||
Edge: call:_operator(str("+"), var(s1), str(" ")) -> call:_operator(str("+"), call:_operator(str("+"), var(s1), str(" ")), var(s2)) # a
|
Vertex: FuncValue
|
||||||
Edge: call:_operator(str("+"), var(s1), str(" ")) -> call:_operator(str("+"), call:_operator(str("+"), var(s1), str(" ")), var(s2)) # a
|
Vertex: FuncValue
|
||||||
Edge: func() { call:_operator(str("+"), call:_operator(str("+"), var(s1), str(" ")), var(s2)) } -> call:fn() # call:fn
|
Vertex: call
|
||||||
Edge: func() { call:_operator(str("+"), call:_operator(str("+"), var(s1), str(" ")), var(s2)) } -> call:fn() # call:fn
|
Vertex: call
|
||||||
Edge: func() { call:_operator(str("+"), call:_operator(str("+"), var(s1), str(" ")), var(s2)) } -> call:fn() # call:fn
|
Vertex: call
|
||||||
Edge: str(" ") -> call:_operator(str("+"), var(s1), str(" ")) # b
|
Vertex: const
|
||||||
Edge: str(" ") -> call:_operator(str("+"), var(s1), str(" ")) # b
|
Vertex: const
|
||||||
Edge: str(" ") -> call:_operator(str("+"), var(s1), str(" ")) # b
|
Vertex: const
|
||||||
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)
|
|
||||||
|
|||||||
10
lang/interpret_test/TestAstFunc2/chained-vars.txtar
Normal file
10
lang/interpret_test/TestAstFunc2/chained-vars.txtar
Normal 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]
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
-- main.mcl --
|
-- main.mcl --
|
||||||
$x1 = "bad1"
|
$x1 = "bad1"
|
||||||
|
$x2 = "also bad"
|
||||||
include defs.foo
|
include defs.foo
|
||||||
|
|
||||||
import "defs.mcl" # out of order for fun
|
import "defs.mcl" # out of order for fun
|
||||||
|
|||||||
25
lang/interpret_test/TestAstFunc2/complex-example.txtar
Normal file
25
lang/interpret_test/TestAstFunc2/complex-example.txtar
Normal 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]
|
||||||
19
lang/interpret_test/TestAstFunc2/definition-site-scope.txtar
Normal file
19
lang/interpret_test/TestAstFunc2/definition-site-scope.txtar
Normal 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?]
|
||||||
11
lang/interpret_test/TestAstFunc2/func-duplicate-arg.txtar
Normal file
11
lang/interpret_test/TestAstFunc2/func-duplicate-arg.txtar
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
-- main.mcl --
|
||||||
|
# function statement
|
||||||
|
func stradd($x) {
|
||||||
|
$x + $x
|
||||||
|
}
|
||||||
|
|
||||||
|
$x1 = stradd("hey")
|
||||||
|
|
||||||
|
test $x1 {}
|
||||||
|
-- OUTPUT --
|
||||||
|
Vertex: test[heyhey]
|
||||||
@@ -2,20 +2,14 @@
|
|||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
# function statement
|
# function statement
|
||||||
func sq1($x, $y) {
|
func sq1($x) {
|
||||||
$y + $x * $x
|
$x + $x
|
||||||
|
#$x + 3
|
||||||
|
#6
|
||||||
}
|
}
|
||||||
|
|
||||||
# function expression
|
$x1 = sq1(3) # 3^2 + 4 = 13
|
||||||
$sq2 = func($x, $y) {
|
|
||||||
$y + $x * $x
|
|
||||||
}
|
|
||||||
|
|
||||||
$x1 = sq1(3, 4) # 3^2 + 4 = 13
|
|
||||||
$x2 = $sq2(7, -7) # 7^2 + 2 = 42
|
|
||||||
|
|
||||||
test fmt.printf("sq1: %d", $x1) {}
|
test fmt.printf("sq1: %d", $x1) {}
|
||||||
test fmt.printf("sq2: %d", $x2) {}
|
|
||||||
-- OUTPUT --
|
-- OUTPUT --
|
||||||
Vertex: test[sq1: 13]
|
Vertex: test[sq1: 6]
|
||||||
Vertex: test[sq2: 42]
|
|
||||||
|
|||||||
17
lang/interpret_test/TestAstFunc2/func-math2.txtar
Normal file
17
lang/interpret_test/TestAstFunc2/func-math2.txtar
Normal 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]
|
||||||
13
lang/interpret_test/TestAstFunc2/func-one-arg.txtar
Normal file
13
lang/interpret_test/TestAstFunc2/func-one-arg.txtar
Normal 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]
|
||||||
13
lang/interpret_test/TestAstFunc2/func-unused-arg.txtar
Normal file
13
lang/interpret_test/TestAstFunc2/func-unused-arg.txtar
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
-- main.mcl --
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
# function statement
|
||||||
|
func stradd($x) {
|
||||||
|
"nothing"
|
||||||
|
}
|
||||||
|
|
||||||
|
$x1 = stradd("hey")
|
||||||
|
|
||||||
|
test $x1 {}
|
||||||
|
-- OUTPUT --
|
||||||
|
Vertex: test[nothing]
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
-- main.mcl --
|
||||||
|
# function statement
|
||||||
|
func identity($x) {
|
||||||
|
$x
|
||||||
|
}
|
||||||
|
|
||||||
|
test identity("hey") {}
|
||||||
|
-- OUTPUT --
|
||||||
|
Vertex: test[hey]
|
||||||
10
lang/interpret_test/TestAstFunc2/if-0.txtar
Normal file
10
lang/interpret_test/TestAstFunc2/if-0.txtar
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
-- main.mcl --
|
||||||
|
$out1 = if true {
|
||||||
|
"hello"
|
||||||
|
} else {
|
||||||
|
"world"
|
||||||
|
}
|
||||||
|
|
||||||
|
test $out1 {}
|
||||||
|
-- OUTPUT --
|
||||||
|
Vertex: test[hello]
|
||||||
15
lang/interpret_test/TestAstFunc2/if-in-func-0.txtar
Normal file
15
lang/interpret_test/TestAstFunc2/if-in-func-0.txtar
Normal 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]
|
||||||
@@ -10,4 +10,4 @@ print "msg" {
|
|||||||
msg => fmt.printf("notfn: %d", $x),
|
msg => fmt.printf("notfn: %d", $x),
|
||||||
}
|
}
|
||||||
-- OUTPUT --
|
-- OUTPUT --
|
||||||
# err: errUnify: expected: Func, got: Int
|
# err: errUnify: func arg count differs
|
||||||
|
|||||||
13
lang/interpret_test/TestAstFunc2/lambda-duplicate-arg.txtar
Normal file
13
lang/interpret_test/TestAstFunc2/lambda-duplicate-arg.txtar
Normal 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]
|
||||||
8
lang/interpret_test/TestAstFunc2/lambda-no-args1.txtar
Normal file
8
lang/interpret_test/TestAstFunc2/lambda-no-args1.txtar
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
-- main.mcl --
|
||||||
|
$hey = func() {
|
||||||
|
"hello"
|
||||||
|
}
|
||||||
|
|
||||||
|
test $hey() {}
|
||||||
|
-- OUTPUT --
|
||||||
|
Vertex: test[hello]
|
||||||
13
lang/interpret_test/TestAstFunc2/lambda-one-arg.txtar
Normal file
13
lang/interpret_test/TestAstFunc2/lambda-one-arg.txtar
Normal 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]
|
||||||
6
lang/interpret_test/TestAstFunc2/lambda-one-func.txtar
Normal file
6
lang/interpret_test/TestAstFunc2/lambda-one-func.txtar
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
-- main.mcl --
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
test fmt.printf("hello: %d", 42) {}
|
||||||
|
-- OUTPUT --
|
||||||
|
Vertex: test[hello: 42]
|
||||||
13
lang/interpret_test/TestAstFunc2/lambda-unused-arg.txtar
Normal file
13
lang/interpret_test/TestAstFunc2/lambda-unused-arg.txtar
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
-- main.mcl --
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
# function statement
|
||||||
|
$stradd = func($x) {
|
||||||
|
"nothing"
|
||||||
|
}
|
||||||
|
|
||||||
|
$x1 = $stradd("hey")
|
||||||
|
|
||||||
|
test $x1 {}
|
||||||
|
-- OUTPUT --
|
||||||
|
Vertex: test[nothing]
|
||||||
10
lang/interpret_test/TestAstFunc2/map-ignore-arg.txtar
Normal file
10
lang/interpret_test/TestAstFunc2/map-ignore-arg.txtar
Normal 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]
|
||||||
13
lang/interpret_test/TestAstFunc2/map-numbered.txtar
Normal file
13
lang/interpret_test/TestAstFunc2/map-numbered.txtar
Normal 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]
|
||||||
2
lang/interpret_test/TestAstFunc2/res0.txtar
Normal file
2
lang/interpret_test/TestAstFunc2/res0.txtar
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
-- main.mcl --
|
||||||
|
-- OUTPUT --
|
||||||
6
lang/interpret_test/TestAstFunc2/res1.txtar
Normal file
6
lang/interpret_test/TestAstFunc2/res1.txtar
Normal 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)
|
||||||
8
lang/interpret_test/TestAstFunc2/res2.txtar
Normal file
8
lang/interpret_test/TestAstFunc2/res2.txtar
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
-- main.mcl --
|
||||||
|
test "t1" {
|
||||||
|
int64ptr => 42,
|
||||||
|
stringptr => "okay cool",
|
||||||
|
int8ptrptrptr => 127, # super nested
|
||||||
|
}
|
||||||
|
-- OUTPUT --
|
||||||
|
Vertex: test[t1]
|
||||||
13
lang/interpret_test/TestAstFunc2/res3.txtar
Normal file
13
lang/interpret_test/TestAstFunc2/res3.txtar
Normal 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]
|
||||||
37
lang/interpret_test/TestAstFunc2/res4.txtar
Normal file
37
lang/interpret_test/TestAstFunc2/res4.txtar
Normal 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]
|
||||||
8
lang/interpret_test/TestAstFunc2/template-1.txtar
Normal file
8
lang/interpret_test/TestAstFunc2/template-1.txtar
Normal 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]
|
||||||
78
lang/interpret_test/TestAstFunc2/very-complex-example.txtar
Normal file
78
lang/interpret_test/TestAstFunc2/very-complex-example.txtar
Normal 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)
|
||||||
Reference in New Issue
Block a user