-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from savi-lang/add/cross-platform
Add C++ tests for cross-platform error code checks.
- Loading branch information
Showing
5 changed files
with
86 additions
and
5 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
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
:: Print a C++ program that checks the mapping of error codes by names, | ||
:: comparing what we have implemented to what the C++ compiler resolves. | ||
:: | ||
:: For this C++ program to compile, all of the `static_assert`s must pass, | ||
:: which means all of our error code mappings in Savi must be correct. | ||
:: | ||
:: Therefore we can test our error code mappings py piping the printed C++ code | ||
:: into a C++ compiler, with a command like this: | ||
:: ``` | ||
:: savi run c++-check-program | c++ -x c++ -o /dev/null - | ||
:: ``` | ||
:actor Main | ||
:new (env) | ||
env.out.print("#include <errno.h>") | ||
|
||
OSError.each_supported_in_platform -> (error | | ||
next if error == 0 | ||
|
||
env.out.print("static_assert( \ | ||
\(error.name) == \(error.u32), \ | ||
\"\(error.name) == \(error.u32)\" \ | ||
);") | ||
) | ||
|
||
env.out.print("int main() { return 0; }") |
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