Skip to content

Commit

Permalink
lang: Quote printed strings
Browse files Browse the repository at this point in the history
This quotes printed strings that contain special characters such as
newline. This changes the output of some tests, but makes future tests
that include a raw \n more appropriate.
  • Loading branch information
purpleidea committed Apr 24, 2019
1 parent 8f1f5d3 commit 97d60ac
Show file tree
Hide file tree
Showing 10 changed files with 194 additions and 193 deletions.
30 changes: 15 additions & 15 deletions lang/interpret_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func TestAstFunc0(t *testing.T) {
}
{
graph, _ := pgraph.NewGraph("g")
v1, v2, v3, v4, v5 := vtex("int(42)"), vtex("var(a)"), vtex("var(b)"), vtex("var(c)"), vtex("str(t)")
v1, v2, v3, v4, v5 := vtex("int(42)"), vtex("var(a)"), vtex("var(b)"), vtex("var(c)"), vtex(`str("t")`)
e1, e2, e3 := edge("a"), edge("b"), edge("c")
graph.AddVertex(&v1, &v2, &v3, &v4, &v5)
graph.AddEdge(&v1, &v2, &e1)
Expand Down Expand Up @@ -179,7 +179,7 @@ func TestAstFunc0(t *testing.T) {
}
{
graph, _ := pgraph.NewGraph("g")
v1, v2, v3, v4, v5 := vtex("str(t)"), vtex("str(+)"), vtex("int(42)"), vtex("int(13)"), vtex(fmt.Sprintf("call:%s(str(+), int(42), int(13))", operatorFuncName))
v1, v2, v3, v4, v5 := vtex(`str("t")`), vtex(`str("+")`), vtex("int(42)"), vtex("int(13)"), vtex(fmt.Sprintf(`call:%s(str("+"), int(42), int(13))`, operatorFuncName))
graph.AddVertex(&v1, &v2, &v3, &v4, &v5)
e1, e2, e3 := edge("x"), edge("a"), edge("b")
graph.AddEdge(&v2, &v5, &e1)
Expand All @@ -199,10 +199,10 @@ func TestAstFunc0(t *testing.T) {
}
{
graph, _ := pgraph.NewGraph("g")
v1, v2, v3 := vtex("str(t)"), vtex("str(-)"), vtex("str(+)")
v1, v2, v3 := vtex(`str("t")`), vtex(`str("-")`), vtex(`str("+")`)
v4, v5, v6 := vtex("int(42)"), vtex("int(13)"), vtex("int(99)")
v7 := vtex(fmt.Sprintf("call:%s(str(+), int(42), int(13))", operatorFuncName))
v8 := vtex(fmt.Sprintf("call:%s(str(-), call:%s(str(+), int(42), int(13)), int(99))", operatorFuncName, operatorFuncName))
v7 := vtex(fmt.Sprintf(`call:%s(str("+"), int(42), int(13))`, operatorFuncName))
v8 := vtex(fmt.Sprintf(`call:%s(str("-"), call:%s(str("+"), int(42), int(13)), int(99))`, operatorFuncName, operatorFuncName))

graph.AddVertex(&v1, &v2, &v3, &v4, &v5, &v6, &v7, &v8)
e1, e2, e3 := edge("x"), edge("a"), edge("b")
Expand All @@ -228,10 +228,10 @@ func TestAstFunc0(t *testing.T) {
}
{
graph, _ := pgraph.NewGraph("g")
v1, v2 := vtex("bool(true)"), vtex("str(t)")
v1, v2 := vtex("bool(true)"), vtex(`str("t")`)
v3, v4 := vtex("int(13)"), vtex("int(42)")
v5, v6 := vtex("var(i)"), vtex("var(x)")
v7, v8 := vtex("str(+)"), vtex(fmt.Sprintf("call:%s(str(+), int(42), var(i))", operatorFuncName))
v7, v8 := vtex(`str("+")`), vtex(fmt.Sprintf(`call:%s(str("+"), int(42), var(i))`, operatorFuncName))

e1, e2, e3, e4, e5 := edge("x"), edge("a"), edge("b"), edge("i"), edge("x")
graph.AddVertex(&v1, &v2, &v3, &v4, &v5, &v6, &v7, &v8)
Expand Down Expand Up @@ -285,8 +285,8 @@ func TestAstFunc0(t *testing.T) {
}
{
graph, _ := pgraph.NewGraph("g")
v1, v2, v3 := vtex("str(hello)"), vtex("str(world)"), vtex("bool(true)")
v4, v5 := vtex("var(x)"), vtex("str(t)")
v1, v2, v3 := vtex(`str("hello")`), vtex(`str("world")`), vtex("bool(true)")
v4, v5 := vtex("var(x)"), vtex(`str("t")`)

graph.AddVertex(&v1, &v2, &v3, &v4, &v5)
e1 := edge("x")
Expand All @@ -311,8 +311,8 @@ func TestAstFunc0(t *testing.T) {
}
{
graph, _ := pgraph.NewGraph("g")
v1, v2, v3 := vtex("str(hello)"), vtex("str(world)"), vtex("bool(true)")
v4, v5 := vtex("var(x)"), vtex("str(t)")
v1, v2, v3 := vtex(`str("hello")`), vtex(`str("world")`), vtex("bool(true)")
v4, v5 := vtex("var(x)"), vtex(`str("t")`)

graph.AddVertex(&v1, &v2, &v3, &v4, &v5)
e1 := edge("x")
Expand All @@ -339,9 +339,9 @@ func TestAstFunc0(t *testing.T) {
//{
// graph, _ := pgraph.NewGraph("g")
// v0 := vtex("bool(true)")
// v1, v2 := vtex("str(hello)"), vtex("str(world)")
// v1, v2 := vtex(`str("hello")`), vtex(`str("world")`)
// v3, v4 := vtex("var(x)"), vtex("var(x)") // different vertices!
// v5, v6 := vtex("str(t1)"), vtex("str(t2)")
// v5, v6 := vtex(`str("t1")`), vtex(`str("t2")`)
//
// graph.AddVertex(&v0, &v1, &v2, &v3, &v4, &v5, &v6)
// e1, e2 := edge("x"), edge("x")
Expand Down Expand Up @@ -370,8 +370,8 @@ func TestAstFunc0(t *testing.T) {
// // FIXME: blocked by: https://github.com/purpleidea/mgmt/issues/199
//{
// graph, _ := pgraph.NewGraph("g")
// v1, v2 := vtex("str(cowsay)"), vtex("str(cowsay)")
// v3, v4 := vtex("str(installed)"), vtex("str(newest)")
// v1, v2 := vtex(`str("cowsay")`), vtex(`str("cowsay")`)
// v3, v4 := vtex(`str("installed)`), vtex(`str("newest")`)
//
// graph.AddVertex(&v1, &v2, &v3, &v4)
//
Expand Down
20 changes: 10 additions & 10 deletions lang/interpret_test/TestAstFunc1/duplicate_resource.graph
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Edge: str(hello world) -> call:fmt.printf(str(hello world)) # a
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: str("hello world") -> call:fmt.printf(str("hello world")) # a
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")
20 changes: 10 additions & 10 deletions lang/interpret_test/TestAstFunc1/empty-res-list-0.graph
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Edge: list(str(hey)) -> var(names) # 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
Edge: list(str("hey")) -> var(names) # 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()
Vertex: list(str(hello), str(world))
Vertex: list(str(hey))
Vertex: str(hello)
Vertex: str(hey)
Vertex: str(name)
Vertex: str(world)
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)
14 changes: 7 additions & 7 deletions lang/interpret_test/TestAstFunc1/hello0.graph
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Vertex: call:fmt.printf(str(hello: %s), var(s))
Vertex: str(greeting)
Vertex: str(hello: %s)
Vertex: str(world)
Edge: str("hello: %s") -> call:fmt.printf(str("hello: %s"), var(s)) # a
Edge: str("world") -> var(s) # s
Edge: var(s) -> call:fmt.printf(str("hello: %s"), var(s)) # b
Vertex: call:fmt.printf(str("hello: %s"), var(s))
Vertex: str("greeting")
Vertex: str("hello: %s")
Vertex: str("world")
Vertex: var(s)
Edge: str(hello: %s) -> call:fmt.printf(str(hello: %s), var(s)) # a
Edge: str(world) -> var(s) # s
Edge: var(s) -> call:fmt.printf(str(hello: %s), var(s)) # b
10 changes: 5 additions & 5 deletions lang/interpret_test/TestAstFunc1/importscope0.graph
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Edge: call:os.is_debian() -> if(call:os.is_debian()) # c
Edge: if(call:os.is_debian()) -> var(aaa) # aaa
Edge: str(bbb) -> if(call:os.is_debian()) # a
Edge: str(ccc) -> if(call:os.is_debian()) # b
Edge: str("bbb") -> if(call:os.is_debian()) # a
Edge: str("ccc") -> if(call:os.is_debian()) # b
Vertex: call:os.is_debian()
Vertex: if(call:os.is_debian())
Vertex: str(bbb)
Vertex: str(ccc)
Vertex: str(hello)
Vertex: str("bbb")
Vertex: str("ccc")
Vertex: str("hello")
Vertex: var(aaa)
10 changes: 5 additions & 5 deletions lang/interpret_test/TestAstFunc1/importscope2.graph
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Edge: call:os.is_debian() -> if(call:os.is_debian()) # c
Edge: if(call:os.is_debian()) -> var(aaa) # aaa
Edge: str(bbb) -> if(call:os.is_debian()) # a
Edge: str(ccc) -> if(call:os.is_debian()) # b
Edge: str("bbb") -> if(call:os.is_debian()) # a
Edge: str("ccc") -> if(call:os.is_debian()) # b
Vertex: call:os.is_debian()
Vertex: if(call:os.is_debian())
Vertex: str(bbb)
Vertex: str(ccc)
Vertex: str(hello)
Vertex: str("bbb")
Vertex: str("ccc")
Vertex: str("hello")
Vertex: var(aaa)
44 changes: 22 additions & 22 deletions lang/interpret_test/TestAstFunc1/metaparams0.graph
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
Edge: bool(false) -> struct(noop: bool(false); retry: int(-1); delay: int(0); poll: int(5); limit: float(4.2); burst: int(3); sema: list(str(foo:1), str(bar:3)); rewatch: bool(false); realize: bool(true); reverse: bool(true); autoedge: bool(true); autogroup: bool(true)) # noop
Edge: bool(false) -> struct(noop: bool(false); retry: int(-1); delay: int(0); poll: int(5); limit: float(4.2); burst: int(3); sema: list(str(foo:1), str(bar:3)); rewatch: bool(false); realize: bool(true); reverse: bool(true); autoedge: bool(true); autogroup: bool(true)) # rewatch
Edge: bool(true) -> struct(noop: bool(false); retry: int(-1); delay: int(0); poll: int(5); limit: float(4.2); burst: int(3); sema: list(str(foo:1), str(bar:3)); rewatch: bool(false); realize: bool(true); reverse: bool(true); autoedge: bool(true); autogroup: bool(true)) # autoedge
Edge: bool(true) -> struct(noop: bool(false); retry: int(-1); delay: int(0); poll: int(5); limit: float(4.2); burst: int(3); sema: list(str(foo:1), str(bar:3)); rewatch: bool(false); realize: bool(true); reverse: bool(true); autoedge: bool(true); autogroup: bool(true)) # autogroup
Edge: bool(true) -> struct(noop: bool(false); retry: int(-1); delay: int(0); poll: int(5); limit: float(4.2); burst: int(3); sema: list(str(foo:1), str(bar:3)); rewatch: bool(false); realize: bool(true); reverse: bool(true); autoedge: bool(true); autogroup: bool(true)) # realize
Edge: bool(true) -> struct(noop: bool(false); retry: int(-1); delay: int(0); poll: int(5); limit: float(4.2); burst: int(3); sema: list(str(foo:1), str(bar:3)); rewatch: bool(false); realize: bool(true); reverse: bool(true); autoedge: bool(true); autogroup: bool(true)) # reverse
Edge: bool(false) -> struct(noop: bool(false); retry: int(-1); delay: int(0); poll: int(5); limit: float(4.2); burst: int(3); sema: list(str("foo:1"), str("bar:3")); rewatch: bool(false); realize: bool(true); reverse: bool(true); autoedge: bool(true); autogroup: bool(true)) # noop
Edge: bool(false) -> struct(noop: bool(false); retry: int(-1); delay: int(0); poll: int(5); limit: float(4.2); burst: int(3); sema: list(str("foo:1"), str("bar:3")); rewatch: bool(false); realize: bool(true); reverse: bool(true); autoedge: bool(true); autogroup: bool(true)) # rewatch
Edge: bool(true) -> struct(noop: bool(false); retry: int(-1); delay: int(0); poll: int(5); limit: float(4.2); burst: int(3); sema: list(str("foo:1"), str("bar:3")); rewatch: bool(false); realize: bool(true); reverse: bool(true); autoedge: bool(true); autogroup: bool(true)) # autoedge
Edge: bool(true) -> struct(noop: bool(false); retry: int(-1); delay: int(0); poll: int(5); limit: float(4.2); burst: int(3); sema: list(str("foo:1"), str("bar:3")); rewatch: bool(false); realize: bool(true); reverse: bool(true); autoedge: bool(true); autogroup: bool(true)) # autogroup
Edge: bool(true) -> struct(noop: bool(false); retry: int(-1); delay: int(0); poll: int(5); limit: float(4.2); burst: int(3); sema: list(str("foo:1"), str("bar:3")); rewatch: bool(false); realize: bool(true); reverse: bool(true); autoedge: bool(true); autogroup: bool(true)) # realize
Edge: bool(true) -> struct(noop: bool(false); retry: int(-1); delay: int(0); poll: int(5); limit: float(4.2); burst: int(3); sema: list(str("foo:1"), str("bar:3")); rewatch: bool(false); realize: bool(true); reverse: bool(true); autoedge: bool(true); autogroup: bool(true)) # reverse
Edge: bool(true) -> var(b) # b
Edge: bool(true) -> var(b) # b
Edge: float(4.2) -> struct(noop: bool(false); retry: int(-1); delay: int(0); poll: int(5); limit: float(4.2); burst: int(3); sema: list(str(foo:1), str(bar:3)); rewatch: bool(false); realize: bool(true); reverse: bool(true); autoedge: bool(true); autogroup: bool(true)) # limit
Edge: int(-1) -> struct(noop: bool(false); retry: int(-1); delay: int(0); poll: int(5); limit: float(4.2); burst: int(3); sema: list(str(foo:1), str(bar:3)); rewatch: bool(false); realize: bool(true); reverse: bool(true); autoedge: bool(true); autogroup: bool(true)) # retry
Edge: int(0) -> struct(noop: bool(false); retry: int(-1); delay: int(0); poll: int(5); limit: float(4.2); burst: int(3); sema: list(str(foo:1), str(bar:3)); rewatch: bool(false); realize: bool(true); reverse: bool(true); autoedge: bool(true); autogroup: bool(true)) # delay
Edge: int(3) -> struct(noop: bool(false); retry: int(-1); delay: int(0); poll: int(5); limit: float(4.2); burst: int(3); sema: list(str(foo:1), str(bar:3)); rewatch: bool(false); realize: bool(true); reverse: bool(true); autoedge: bool(true); autogroup: bool(true)) # burst
Edge: int(5) -> struct(noop: bool(false); retry: int(-1); delay: int(0); poll: int(5); limit: float(4.2); burst: int(3); sema: list(str(foo:1), str(bar:3)); rewatch: bool(false); realize: bool(true); reverse: bool(true); autoedge: bool(true); autogroup: bool(true)) # poll
Edge: list(str(foo:1), str(bar:3)) -> struct(noop: bool(false); retry: int(-1); delay: int(0); poll: int(5); limit: float(4.2); burst: int(3); sema: list(str(foo:1), str(bar:3)); rewatch: bool(false); realize: bool(true); reverse: bool(true); autoedge: bool(true); autogroup: bool(true)) # sema
Edge: str(bar:3) -> list(str(foo:1), str(bar:3)) # 1
Edge: str(foo:1) -> list(str(foo:1), str(bar:3)) # 0
Edge: str(hello world) -> call:fmt.printf(str(hello world)) # a
Edge: float(4.2) -> struct(noop: bool(false); retry: int(-1); delay: int(0); poll: int(5); limit: float(4.2); burst: int(3); sema: list(str("foo:1"), str("bar:3")); rewatch: bool(false); realize: bool(true); reverse: bool(true); autoedge: bool(true); autogroup: bool(true)) # limit
Edge: int(-1) -> struct(noop: bool(false); retry: int(-1); delay: int(0); poll: int(5); limit: float(4.2); burst: int(3); sema: list(str("foo:1"), str("bar:3")); rewatch: bool(false); realize: bool(true); reverse: bool(true); autoedge: bool(true); autogroup: bool(true)) # retry
Edge: int(0) -> struct(noop: bool(false); retry: int(-1); delay: int(0); poll: int(5); limit: float(4.2); burst: int(3); sema: list(str("foo:1"), str("bar:3")); rewatch: bool(false); realize: bool(true); reverse: bool(true); autoedge: bool(true); autogroup: bool(true)) # delay
Edge: int(3) -> struct(noop: bool(false); retry: int(-1); delay: int(0); poll: int(5); limit: float(4.2); burst: int(3); sema: list(str("foo:1"), str("bar:3")); rewatch: bool(false); realize: bool(true); reverse: bool(true); autoedge: bool(true); autogroup: bool(true)) # burst
Edge: int(5) -> struct(noop: bool(false); retry: int(-1); delay: int(0); poll: int(5); limit: float(4.2); burst: int(3); sema: list(str("foo:1"), str("bar:3")); rewatch: bool(false); realize: bool(true); reverse: bool(true); autoedge: bool(true); autogroup: bool(true)) # poll
Edge: list(str("foo:1"), str("bar:3")) -> struct(noop: bool(false); retry: int(-1); delay: int(0); poll: int(5); limit: float(4.2); burst: int(3); sema: list(str("foo:1"), str("bar:3")); rewatch: bool(false); realize: bool(true); reverse: bool(true); autoedge: bool(true); autogroup: bool(true)) # sema
Edge: str("bar:3") -> list(str("foo:1"), str("bar:3")) # 1
Edge: str("foo:1") -> list(str("foo:1"), str("bar:3")) # 0
Edge: str("hello world") -> call:fmt.printf(str("hello world")) # a
Vertex: bool(false)
Vertex: bool(false)
Vertex: bool(false)
Expand All @@ -26,18 +26,18 @@ Vertex: bool(true)
Vertex: bool(true)
Vertex: bool(true)
Vertex: bool(true)
Vertex: call:fmt.printf(str(hello world))
Vertex: call:fmt.printf(str("hello world"))
Vertex: float(4.2)
Vertex: int(-1)
Vertex: int(0)
Vertex: int(3)
Vertex: int(42)
Vertex: int(5)
Vertex: list(str(foo:1), str(bar:3))
Vertex: str(bar:3)
Vertex: str(foo:1)
Vertex: str(greeting)
Vertex: str(hello world)
Vertex: struct(noop: bool(false); retry: int(-1); delay: int(0); poll: int(5); limit: float(4.2); burst: int(3); sema: list(str(foo:1), str(bar:3)); rewatch: bool(false); realize: bool(true); reverse: bool(true); autoedge: bool(true); autogroup: bool(true))
Vertex: list(str("foo:1"), str("bar:3"))
Vertex: str("bar:3")
Vertex: str("foo:1")
Vertex: str("greeting")
Vertex: str("hello world")
Vertex: struct(noop: bool(false); retry: int(-1); delay: int(0); poll: int(5); limit: float(4.2); burst: int(3); sema: list(str("foo:1"), str("bar:3")); rewatch: bool(false); realize: bool(true); reverse: bool(true); autoedge: bool(true); autogroup: bool(true))
Vertex: var(b)
Vertex: var(b)
Loading

0 comments on commit 97d60ac

Please sign in to comment.