v2 / vlib / v / tests / builtin_strings_and_interpolation / raw_string_test.v
44 lines · 36 sloc · 744 bytes · 6488041a749df9762348d019c4223908c476f2e2
Raw
1const ca = r'x\n'
2
3const cb = 'x\n'
4
5const cc = ca + cb
6
7const cd = cc + cc
8
9const ce = cd + cd
10
11fn test_raw_string_backslash() {
12 assert r'\' == r'\'
13}
14
15fn test_raw_string_not_escaped_by_transformer() {
16 assert r'a\nb' + r'a\nb' == r'a\nba\nb'
17 assert 'a\nb' + r'a\nb' == 'a\nba\\nb'
18}
19
20fn test_raw_string_backslash_u() {
21 assert r'\u0000004B' == r'\u0000004B'
22 println(r'\u0000004B')
23}
24
25// this test will cause test failure (see #12604)
26// fn test_many_pluses() {
27// a := r'x\n'
28// assert a == ca
29// b := 'x\n'
30// assert b == cb
31// c := a + b
32// assert c == cc // this fails
33// d := c + c
34// assert d == cd
35// e := d + d
36// assert e == ce
37// println(e)
38// result := r'x\nx
39// x\nx
40// x\nx
41// x\nx
42// '
43// assert e == result
44// }
45