-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow additional contract flags, e.g., `assert<Bounds, audit, new_cod…
…e>( ... )`
- Loading branch information
Showing
14 changed files
with
136 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,29 @@ | ||
test_condition_evaluation: (tag) -> bool = { std::cout << tag << "\n"; return true; } | ||
|
||
audit: bool = true; | ||
|
||
main: () = { | ||
// A few basic tests | ||
assert( 1 != 2, "ack, arithmetic is buggy" ); | ||
assert<Type>( typeid(int) != typeid(double), "ack, C types are broken" ); | ||
assert<Unevaluated>( any-grammatical.kind(of, nonsense * here) is "all ignored" ); | ||
|
||
assert( test_condition_evaluation(1), "default" ); // evaluated: prints "1" | ||
assert<Type>( test_condition_evaluation(2), "type" ); // evaluated: prints "2" | ||
// Now test that conditions are only evaluated if there's | ||
// a handler active + any other control flags are enabled | ||
|
||
assert( test_condition_evaluation(1), "default" ); // evaluated: prints "1" | ||
|
||
// Type has a handler | ||
assert<Type>( test_condition_evaluation(2), "type" ); // evaluated: prints "2" | ||
cpp2::Type.set_handler(); | ||
assert<Type>( test_condition_evaluation(3), "type" ); // not evaluated | ||
assert<Unevaluated>( test_condition_evaluation(4) ); // not evaluated | ||
// Type does not have a handler | ||
assert<Type>( test_condition_evaluation(3), "type" ); // not evaluated | ||
|
||
// Bounds has a handler, and audit is true | ||
assert<Bounds, audit>( test_condition_evaluation(4), "type" ); // evaluated: prints "4" | ||
audit = false; | ||
// Bounds has a handler, but audit is false | ||
assert<Bounds, audit>( test_condition_evaluation(5), "type" ); // not evaluated | ||
|
||
assert<Unevaluated>( test_condition_evaluation(6) ); // not evaluated | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
regression-tests/test-results/clang-12/pure2-contracts.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
1 | ||
2 | ||
4 |
1 change: 1 addition & 0 deletions
1
regression-tests/test-results/gcc-10/pure2-contracts.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
1 | ||
2 | ||
4 |
24 changes: 12 additions & 12 deletions
24
regression-tests/test-results/gcc-10/pure2-print.cpp.output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
In file included from pure2-print.cpp:7: | ||
../../../include/cpp2util.h:10005:33: error: expected unqualified-id before ‘static_assert’ | ||
pure2-print.cpp2:7:1: note: in expansion of macro ‘CPP2_REQUIRES_’ | ||
pure2-print.cpp2:65:59: error: expected ‘;’ at end of member declaration | ||
pure2-print.cpp2:9:1: note: in expansion of macro ‘CPP2_REQUIRES_’ | ||
pure2-print.cpp2:67:59: error: expected ‘;’ at end of member declaration | ||
In file included from pure2-print.cpp:7: | ||
../../../include/cpp2util.h:10005:47: error: static assertion failed: GCC 11 or higher is required to support variables and type-scope functions that have a 'requires' clause. This includes a type-scope 'forward' parameter of non-wildcard type, such as 'func: (this, forward s: std::string)', which relies on being able to add a 'requires' clause - in that case, use 'forward s: _' instead if you need the result to compile with GCC 10. | ||
pure2-print.cpp2:66:1: note: in expansion of macro ‘CPP2_REQUIRES_’ | ||
pure2-print.cpp2:68:1: note: in expansion of macro ‘CPP2_REQUIRES_’ | ||
../../../include/cpp2util.h:10005:33: error: expected initializer before ‘static_assert’ | ||
pure2-print.cpp2:94:1: note: in expansion of macro ‘CPP2_REQUIRES_’ | ||
pure2-print.cpp2:7:41: error: ‘constexpr const T outer::object_alias’ is not a static data member of ‘class outer’ | ||
pure2-print.cpp2:7:48: error: template definition of non-template ‘constexpr const T outer::object_alias’ | ||
pure2-print.cpp2:65:14: error: no declaration matches ‘void outer::mytype::variadic(const auto:90& ...) requires (is_convertible_v<typename std::remove_cv<typename std::remove_reference<decltype(outer::mytype::variadic::x)>::type>::type, int> && ...)’ | ||
pure2-print.cpp2:65:29: note: candidate is: ‘template<class ... auto:89> static void outer::mytype::variadic(const auto:89& ...)’ | ||
pure2-print.cpp2:8:19: note: ‘class outer::mytype’ defined here | ||
pure2-print.cpp2:93:37: error: no declaration matches ‘void outer::print(std::ostream&, const Args& ...) requires cpp2::cmp_greater_eq(sizeof (Args)..., 0)’ | ||
pure2-print.cpp2:93:37: note: no functions named ‘void outer::print(std::ostream&, const Args& ...) requires cpp2::cmp_greater_eq(sizeof (Args)..., 0)’ | ||
pure2-print.cpp2:4:7: note: ‘class outer’ defined here | ||
pure2-print.cpp2:96:1: note: in expansion of macro ‘CPP2_REQUIRES_’ | ||
pure2-print.cpp2:9:41: error: ‘constexpr const T outer::object_alias’ is not a static data member of ‘class outer’ | ||
pure2-print.cpp2:9:48: error: template definition of non-template ‘constexpr const T outer::object_alias’ | ||
pure2-print.cpp2:67:14: error: no declaration matches ‘void outer::mytype::variadic(const auto:90& ...) requires (is_convertible_v<typename std::remove_cv<typename std::remove_reference<decltype(outer::mytype::variadic::x)>::type>::type, int> && ...)’ | ||
pure2-print.cpp2:67:29: note: candidate is: ‘template<class ... auto:89> static void outer::mytype::variadic(const auto:89& ...)’ | ||
pure2-print.cpp2:10:19: note: ‘class outer::mytype’ defined here | ||
pure2-print.cpp2:95:37: error: no declaration matches ‘void outer::print(std::ostream&, const Args& ...) requires cpp2::cmp_greater_eq(sizeof (Args)..., 0)’ | ||
pure2-print.cpp2:95:37: note: no functions named ‘void outer::print(std::ostream&, const Args& ...) requires cpp2::cmp_greater_eq(sizeof (Args)..., 0)’ | ||
pure2-print.cpp2:6:7: note: ‘class outer’ defined here |
1 change: 1 addition & 0 deletions
1
regression-tests/test-results/gcc-13/pure2-contracts.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
1 | ||
2 | ||
4 |
1 change: 1 addition & 0 deletions
1
regression-tests/test-results/msvc-2022/pure2-contracts.cpp.execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
1 | ||
2 | ||
4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
"8C17:0658" | ||
"8C17:1133" |
Oops, something went wrong.