forked from denoland/deno
-
Notifications
You must be signed in to change notification settings - Fork 0
/
util_test.go
62 lines (58 loc) · 1.81 KB
/
util_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
50
51
52
53
54
55
56
57
58
59
60
61
62
package deno
import (
"testing"
)
const exStackTrace = `hello
before error
error Error: error
at foo (/Users/rld/go/src/github.com/ry/deno/testdata/013_async_throw.ts:4:11)
at eval (/Users/rld/go/src/github.com/ry/deno/testdata/013_async_throw.ts:6:1)
at Object.eval [as globalEval] (<anonymous>)
at execute (/main.js:144781:15)
at FileModule.compileAndRun (/main.js:144678:13)
at /main.js:145161:13
at /main.js:15733:13`
const exStackTracePattern = `hello
before error
error Error: error
at foo ([WILDCARD]testdata/013_async_throw.ts:4:11)
at eval ([WILDCARD]testdata/013_async_throw.ts:6:1)
at Object.eval [as globalEval] (<anonymous>)
at execute (/main.js:[WILDCARD]`
func TestPatternMatch(t *testing.T) {
if patternMatch("aa", "a") != false {
t.Fatalf("Wrong resullt (1).")
}
if patternMatch("aaa[WILDCARD]b", "aaaxsdfdb") != true {
t.Fatalf("Wrong resullt (2).")
}
if patternMatch("aab[WILDCARD]", "xsd") != false {
t.Fatalf("Wrong resullt (3).")
}
if patternMatch("a[WILDCARD]b[WILDCARD]c", "abc") != true {
t.Fatalf("Wrong resullt (4).")
}
if patternMatch("a[WILDCARD]b[WILDCARD]c", "axbc") != true {
t.Fatalf("Wrong resullt (5).")
}
if patternMatch("a[WILDCARD]b[WILDCARD]c", "abxc") != true {
t.Fatalf("Wrong resullt (6).")
}
if patternMatch("a[WILDCARD]b[WILDCARD]c", "axbxc") != true {
t.Fatalf("Wrong resullt (7).")
}
if patternMatch("a[WILDCARD]b[WILDCARD]c", "abcx") != false {
t.Fatalf("Wrong resullt (8).")
}
if patternMatch("a[WILDCARD][WILDCARD]c", "abc") != true {
t.Fatalf("Wrong resullt (9).")
}
if patternMatch("a[WILDCARD][WILDCARD]c", "ac") != true {
t.Fatalf("Wrong resullt (10).")
}
}
func TestPatternMatchStackTrace(t *testing.T) {
if patternMatch(exStackTracePattern, exStackTrace) != true {
t.Fatalf("Wrong resullt (11).")
}
}