-
Notifications
You must be signed in to change notification settings - Fork 0
/
package_test.go
48 lines (45 loc) · 964 Bytes
/
package_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
package kpp
import (
"fmt"
"os"
"testing"
)
func TestPackage(t *testing.T) {
pkg, err := Open(os.DirFS("testdata/hello"))
if err != nil {
t.Fatal(err)
}
fmt.Printf("Metadata: %v\n", pkg.Metadata())
stmts, err := pkg.Statements()
if err != nil {
t.Fatal(err)
}
fmt.Printf("Statements: %v\n", stmts)
tests, err := pkg.TestData()
if err != nil {
t.Fatal(err)
}
fmt.Printf("Tests:\n")
for _, e := range tests {
fmt.Printf(" %v\n", e)
fmt.Printf(" Name: %s\n", e.Name())
fmt.Printf(" Group: %s\n", e.Group())
fmt.Printf(" Hint: %s\n", mustString(t)(e.Hint()))
fmt.Printf(" Description: %s\n", mustString(t)(e.Description()))
fmt.Println()
}
subms, err := pkg.Submissions()
if err != nil {
t.Fatal(err)
}
fmt.Printf("Submissions: %v\n", subms)
}
func mustString(t *testing.T) func(s string, err error) string {
return func(s string, err error) string {
if err != nil {
t.Fatal(err)
return ""
}
return s
}
}