Skip to content

Commit 043223e

Browse files
committed
add more tests
1 parent 232e278 commit 043223e

5 files changed

Lines changed: 91 additions & 4 deletions

File tree

lit.cfg.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ def sed_escape(s: str) -> str:
3636
compiler = lit_config.params.get("compiler")
3737
if compiler == "clang":
3838
config.available_features.add("clang")
39-
config.substitutions.append(("%verify", f"not clang++ {clang_flags} %s 2>&1 | FileCheck <({diag_replacements} %s)"))
40-
config.substitutions.append(("%compile", f"clang++ {clang_flags} %s 2>&1"))
39+
config.substitutions.append(("%verify", f"not clang++ {clang_flags} -c %s 2>&1 | FileCheck <({diag_replacements} %s)"))
40+
config.substitutions.append(("%compile", f"clang++ {clang_flags} -c %s 2>&1"))
4141
elif compiler == "gcc":
4242
config.available_features.add("gcc")
43-
config.substitutions.append(("%verify", f"not g++ {gcc_flags} %s 2>&1 | FileCheck <({diag_replacements} %s)"))
44-
config.substitutions.append(("%compile", f"g++ {gcc_flags} %s 2>&1"))
43+
config.substitutions.append(("%verify", f"not g++ {gcc_flags} -c %s 2>&1 | FileCheck <({diag_replacements} %s)"))
44+
config.substitutions.append(("%compile", f"g++ {gcc_flags} -c %s 2>&1"))
4545
else:
4646
print(f"Invalid compiler. Select a compiler with -Dcompiler={{gcc,clang}}")
4747
sys.exit(1)

test/base.verify.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// RUN: %verify
2+
3+
#include <chroma>
4+
5+
struct A {
6+
static constexpr auto error_message = "not in A";
7+
};
8+
9+
struct B : A {
10+
static constexpr auto error_message = "not in B";
11+
};
12+
13+
void fnc1(callable_from<B> = {}) {}
14+
15+
void fnc2(callable_from<A> = {}) {
16+
// STATIC_ASSERT: not in B
17+
fnc1();
18+
}
19+
20+
void fnc3(callable_from<B> = {}) {
21+
fnc2();
22+
}

test/unrelated.verify.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// RUN: %verify
2+
3+
#include <chroma>
4+
5+
struct A {
6+
static constexpr auto error_message = "not in A";
7+
};
8+
9+
struct B {
10+
static constexpr auto error_message = "not in B";
11+
};
12+
13+
void fnc(callable_from<A> = {}) {}
14+
void other_fnc(callable_from<B> = {}) {
15+
// STATIC_ASSERT: not in A
16+
fnc();
17+
}
18+
19+
void test() {
20+
// STATIC_ASSERT: not in B
21+
other_fnc();
22+
}

test/with.pass.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// RUN: %compile
2+
3+
#include <chroma>
4+
5+
struct A {
6+
static constexpr auto error_message = "not in A";
7+
};
8+
9+
struct B {
10+
static constexpr auto error_message = "not in B";
11+
};
12+
13+
void fnc1(callable_from<A> = {}) {}
14+
void fnc2(callable_from<B> = {}) {}
15+
16+
void test() {
17+
$with(A, B) {
18+
fnc1();
19+
fnc2();
20+
};
21+
}

test/with.verify.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// RUN: %verify
2+
3+
#include <chroma>
4+
5+
struct A {
6+
static constexpr auto error_message = "not in A";
7+
};
8+
9+
struct B {
10+
static constexpr auto error_message = "not in B";
11+
};
12+
13+
void fnc1(callable_from<A> = {}) {}
14+
void fnc2(callable_from<B> = {}) {}
15+
16+
void test() {
17+
$with(A) {
18+
fnc1();
19+
// STATIC_ASSERT: not in B
20+
fnc2();
21+
};
22+
}

0 commit comments

Comments
 (0)