Skip to content

Commit a3c1ddf

Browse files
committed
Add regression-tests
1 parent cee7514 commit a3c1ddf

7 files changed

+117
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
main: () -> int = {
2+
i := 42;
3+
m : std::map<std::string, int> = ();
4+
m["one"] = 1;
5+
m["two"] = 2;
6+
7+
str : std::string = "this is a string";
8+
9+
raw_str : std::string = R"string(raw string without interpolation)string";
10+
11+
raw_str_multi : std::string = R"test(this is raw string literal
12+
13+
that can last for multiple
14+
15+
lines)test";
16+
17+
raw_str_inter : std::string = $R"test(this is raw string literal
18+
that can last for multiple
19+
lines
20+
(i)$ R"(this can be added too)"
21+
calculations like m["one"] + m["two"] = (m["one"] + m["two"])$ also works
22+
("at the beginning of the line")$!!!)test";
23+
24+
raw_str_inter_multi : std::string = $R"(
25+
26+
)" + $R"((i)$)" + $R"((i)$)";
27+
28+
std::cout << str << std::endl;
29+
std::cout << raw_str << std::endl;
30+
std::cout << raw_str_multi << std::endl;
31+
std::cout << raw_str_inter << std::endl;
32+
std::cout << raw_str_inter_multi << std::endl;
33+
std::cout << ($R"((m["one"])$.)" + $R"((m["two"])$.)" + $R"((m["three"])$.)" + $R"((i)$)") << std::endl;
34+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
this is a string
2+
raw string without interpolation
3+
this is raw string literal
4+
5+
that can last for multiple
6+
7+
lines
8+
this is raw string literal
9+
that can last for multiple
10+
lines
11+
42 R"(this can be added too)"
12+
calculations like m["one"] + m["two"] = 3 also works
13+
at the beginning of the line!!!
14+
15+
16+
4242
17+
1.2.0.42

regression-tests/test-results/apple-clang-14/pure2-raw-string-literal-and-interpolation.cpp.output

Whitespace-only changes.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
this is a string
2+
raw string without interpolation
3+
this is raw string literal
4+
5+
that can last for multiple
6+
7+
lines
8+
this is raw string literal
9+
that can last for multiple
10+
lines
11+
42 R"(this can be added too)"
12+
calculations like m["one"] + m["two"] = 3 also works
13+
at the beginning of the line!!!
14+
15+
16+
4242
17+
1.2.0.42

regression-tests/test-results/clang-12/pure2-raw-string-literal-and-interpolation.cpp.output

Whitespace-only changes.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
2+
#define CPP2_USE_MODULES Yes
3+
4+
#include "cpp2util.h"
5+
6+
7+
#line 1 "pure2-raw-string-literal-and-interpolation.cpp2"
8+
[[nodiscard]] auto main() -> int;
9+
10+
//=== Cpp2 definitions ==========================================================
11+
12+
#line 1 "pure2-raw-string-literal-and-interpolation.cpp2"
13+
[[nodiscard]] auto main() -> int{
14+
auto i {42};
15+
std::map<std::string,int> m {};
16+
cpp2::assert_in_bounds(m, "one") = 1;
17+
cpp2::assert_in_bounds(m, "two") = 2;
18+
19+
std::string str {"this is a string"};
20+
21+
std::string raw_str {R"string(raw string without interpolation)string"};
22+
23+
std::string raw_str_multi {R"test(this is raw string literal
24+
25+
that can last for multiple
26+
27+
lines)test"};
28+
29+
std::string raw_str_inter {R"test(this is raw string literal
30+
that can last for multiple
31+
lines
32+
)test" + cpp2::to_string(i) + R"test( R"(this can be added too)"
33+
calculations like m["one"] + m["two"] = )test" + cpp2::to_string(cpp2::assert_in_bounds(m, "one") + cpp2::assert_in_bounds(m, "two")) + R"test( also works
34+
)test" + cpp2::to_string("at the beginning of the line") + R"test(!!!)test"};
35+
36+
std::string raw_str_inter_multi {R"(
37+
38+
)" + cpp2::to_string(i) + cpp2::to_string(i)};
39+
40+
std::cout << std::move(str) << std::endl;
41+
std::cout << std::move(raw_str) << std::endl;
42+
std::cout << std::move(raw_str_multi) << std::endl;
43+
std::cout << std::move(raw_str_inter) << std::endl;
44+
std::cout << std::move(raw_str_inter_multi) << std::endl;
45+
std::cout << (cpp2::to_string(cpp2::assert_in_bounds(m, "one")) + R"(.)" + cpp2::to_string(cpp2::assert_in_bounds(m, "two")) + R"(.)" + cpp2::to_string(cpp2::assert_in_bounds(std::move(m), "three")) + R"(.)" + cpp2::to_string(std::move(i))) << std::endl;
46+
}
47+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pure2-raw-string-literal-and-interpolation.cpp2... ok (all Cpp2, passes safety checks)
2+

0 commit comments

Comments
 (0)