-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrevamp_test.go
91 lines (77 loc) · 1.05 KB
/
revamp_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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package testing
import "testing"
func Test_Revamp_Strings(t *testing.T) {
rsl := `
a = "hi"
print(a)
b = "hi\n there"
print(b)
c = "hi\n there {1 + 1} \nfriend"
print(c)
d = "hi \\ \h yo"
print(d)
e = r"hi\n there {1 + 1} \nfriend"
print(e)
f = """
hi
friend
"""
print(f)
g = "{1 + 1:6.7}"
print(g)
` + "h = `\"hi\" 'there' \\`bob\\``" + "\nprint(h)"
setupAndRunCode(t, rsl, "--color=never")
expected := `hi
hi
there
hi
there 2
friend
hi \ \h yo
hi\n there {1 + 1} \nfriend
hi
friend
2.0000000
"hi" 'there'` + " `bob`\n"
assertOnlyOutput(t, stdOutBuffer, expected)
assertNoErrors(t)
}
func Test_Revamp_ForLoop(t *testing.T) {
rsl := `
a = [20, 30, 40, 50, 60]
for n in a:
print(n)
if n > 35:
break
print("after")
for n in a:
print(n)
if n > 35:
continue
print("after")
n = "alice"
for i, l in n:
print(i, l)
`
setupAndRunCode(t, rsl, "--color=never")
expected := `20
after
30
after
40
20
after
30
after
40
50
60
0 a
1 l
2 i
3 c
4 e
`
assertOnlyOutput(t, stdOutBuffer, expected)
assertNoErrors(t)
}