Skip to content

Commit c896061

Browse files
committed
Started adding some (anti-)regression tests
1 parent c958425 commit c896061

14 files changed

+203
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
// Step 1: rename .cpp to .cpp2
3+
4+
#include <iostream>
5+
#include <string>
6+
7+
#pragma auto_inline(on)
8+
9+
// Here's a sample Syntax 1 "Hello world"...
10+
11+
auto main() -> int
12+
{
13+
auto s = std::string{"world\n"};
14+
std::cout << "Hello " << s;
15+
}

regression-tests/mixed-hello.cpp2

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
#include <iostream>
3+
#include <string>
4+
5+
name: () -> std::string = {
6+
s: std::string = "world";
7+
decorate(s);
8+
return s;
9+
}
10+
11+
decorate: (inout s: std::string) = {
12+
s = "[" + s + "]";
13+
}
14+
15+
auto main() -> int {
16+
// name();
17+
std::cout << "Hello " << name() << "\n";
18+
}

regression-tests/pure2-hello.cpp2

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
main: () -> int = {
3+
std::cout << "Hello " << name() << "\n";
4+
}
5+
6+
name: () -> std::string = {
7+
s: std::string = "world";
8+
decorate(s);
9+
return s;
10+
}
11+
12+
decorate: (inout s: std::string) = {
13+
s = "[" + s + "]";
14+
}

regression-tests/run-tests.bat

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@echo off
2+
copy ..\*.cpp2 .
3+
for %%f in (mixed-*.cpp2) do (
4+
echo Starting cppfront.exe %%f
5+
C:\GitHub\cppfront\x64\Debug\cppfront.exe %%f > %%f-output
6+
)
7+
for %%f in (pure2-*.cpp2) do (
8+
echo Starting cppfront.exe %%f -p
9+
C:\GitHub\cppfront\x64\Debug\cppfront.exe %%f -p > %%f-output
10+
)
11+
echo Done
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
// Step 1: rename .cpp to .cpp2
3+
4+
#include <iostream>
5+
#include <string>
6+
7+
#pragma auto_inline(on)
8+
9+
// Here's a sample Syntax 1 "Hello world"...
10+
11+
auto main() -> int
12+
{
13+
auto s = std::string{"world\n"};
14+
std::cout << "Hello " << s;
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
// Step 1: rename .cpp to .cpp2
3+
4+
#include <iostream>
5+
#include <string>
6+
7+
#pragma auto_inline(on)
8+
9+
// Here's a sample Syntax 1 "Hello world"...
10+
11+
auto main() -> int
12+
{
13+
auto s = std::string{"world\n"};
14+
std::cout << "Hello " << s;
15+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
cppfront 0.1.1 compiler
2+
Copyright (C) Herb Sutter
3+
mixed-allcpp1-hello.cpp2... ok (all Cpp1)
4+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// ----- Cpp2 support -----
2+
#include "cpp2util.h"
3+
4+
#line 1 "mixed-hello.cpp2"
5+
6+
#include <iostream>
7+
#include <string>
8+
9+
[[nodiscard]] auto name() noexcept -> std::string;
10+
#line 11 "mixed-hello.cpp2"
11+
auto decorate(std::string& s) noexcept -> void;
12+
#line 14 "mixed-hello.cpp2"
13+
14+
auto main() -> int {
15+
// name();
16+
std::cout << "Hello " << name() << "\n";
17+
}
18+
19+
//=== Cpp2 definitions ==========================================================
20+
21+
#line 4 "mixed-hello.cpp2"
22+
23+
[[nodiscard]] auto name() noexcept -> std::string{
24+
std::string s { "world" };
25+
decorate(s);
26+
return s;
27+
}
28+
29+
auto decorate(std::string& s) noexcept -> void{
30+
s = "[" + s + "]";
31+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
#include <iostream>
3+
#include <string>
4+
5+
name: () -> std::string = {
6+
s: std::string = "world";
7+
decorate(s);
8+
return s;
9+
}
10+
11+
decorate: (inout s: std::string) = {
12+
s = "[" + s + "]";
13+
}
14+
15+
auto main() -> int {
16+
// name();
17+
std::cout << "Hello " << name() << "\n";
18+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
cppfront 0.1.1 compiler
2+
Copyright (C) Herb Sutter
3+
mixed-hello.cpp2... ok (mixed Cpp1/Cpp2, Cpp2 code passes safety checks)
4+

0 commit comments

Comments
 (0)