-
Notifications
You must be signed in to change notification settings - Fork 9
/
scripts_test.go
49 lines (42 loc) · 1.09 KB
/
scripts_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright (c) The Test Authors
// SPDX-License-Identifier: MPL-2.0
package test
import "testing"
func TestPostScript_Label(t *testing.T) {
var s PostScript = &script{label: "\nhello "}
if s.Label() != "hello" {
t.FailNow()
}
}
func TestPostScript_Content(t *testing.T) {
var s PostScript = &script{content: "\nhello "}
if s.Content() != "\thello" {
t.FailNow()
}
}
func TestPostScript_Sprintf(t *testing.T) {
ps := Sprintf("foo %s %d", "baz", 1)
result := run(scripts(ps)...)
exp := "↪ PostScript | annotation ↷\n\tfoo baz 1\n"
if result != exp {
t.Fatalf("exp %s, got %s", exp, result)
}
}
func TestPostScript_KV(t *testing.T) {
ps := Values("one", 1, "foo", "bar")
result := run(scripts(ps)...)
exp := "↪ PostScript | mapping ↷\n\t\"one\" => 1\n\t\"foo\" => \"bar\"\n"
if result != exp {
t.Fatalf("exp %s, got %s", exp, result)
}
}
func TestPostScript_Func(t *testing.T) {
ps := Func(func() string {
return "hello"
})
result := run(scripts(ps)...)
exp := "↪ PostScript | function ↷\n\thello\n"
if result != exp {
t.Fatalf("exp %s, got %s", exp, result)
}
}