reviewing project state, doing some tests.
This commit is contained in:
1 parent
f044c6d5eb
commit
61d53362e8
15 files changed
+530
-155
No files matched your search
+14
-2
@@ -1,3 +1,15 @@
|
||||
# Test
|
||||
# Baseline verification
|
||||
|
||||
The implementation here has been gutted and will be rewritten...
|
||||
The implementation smoke is `verify_baseline.ps1`. It is not a parser corpus.
|
||||
|
||||
From the project root, in a fresh PowerShell process:
|
||||
|
||||
```powershell
|
||||
.\scripts\verify_baseline.ps1 -Mode positive -MirrorRoot ..\gencpp-verify-positive
|
||||
.\scripts\verify_baseline.ps1 -Mode positive -MirrorRoot ..\gencpp-verify-positive -ReuseMirror
|
||||
```
|
||||
|
||||
The first command generates base component tables, segmented C++, single-header C++, and both C11 layouts.
|
||||
It compiles and runs the C++17 and C11 single-header host smokes. The second command reuses the same mirror.
|
||||
|
||||
The verification wrapper copies them into the disposable mirror; it does not embed C or C++ source text.
|
||||
+45
-24
@@ -1,36 +1,57 @@
|
||||
#if INTELLISENSE_DIRECTIVES
|
||||
#include "../../gen_c_library/gen/gen_singleheader.h"
|
||||
#endif
|
||||
|
||||
#define GEN_IMPLEMENTATION
|
||||
#define GEN_DEFINE_LIBRARY_CODE_CONSTANTS
|
||||
#include "gen_singleheader.h"
|
||||
|
||||
#define gen_iterator( Type, container, iter ) \
|
||||
gen_begin_ ## Type(container); \
|
||||
iter != gen_end_ ## Type(container); \
|
||||
code = gen_next_ ## Type(container, iter)
|
||||
gen_global gen_s32 g_failures = 0;
|
||||
|
||||
gen_internal void expect(int condition, gen_Str name) {
|
||||
if (condition == false) { gen_log_fmt("FAIL %S\n", name); ++ g_failures; }
|
||||
}
|
||||
|
||||
gen_internal void expect_fragments(gen_Str text, gen_Str label) {
|
||||
expect(text.Ptr != 0 && text.Len > 0, label);
|
||||
expect(gen_str_contains(text, gen_txt("baseline_message")), label);
|
||||
expect(gen_str_contains(text, gen_txt("char")), label);
|
||||
expect(gen_str_contains(text, gen_txt("const")), label);
|
||||
expect(gen_str_contains(text, gen_txt("*")), label);
|
||||
expect(gen_str_contains(text, gen_txt("GENCPP_BASELINE")), label);
|
||||
}
|
||||
|
||||
gen_internal void expect_variable(gen_CodeVar var, gen_Str label) {
|
||||
expect(var != 0, label); if (var == 0) return;
|
||||
expect(var->Type == CT_Variable, label);
|
||||
expect(gen_str_contains(var->Name, gen_txt("baseline_message")), label);
|
||||
expect(var->ValueType != 0, label);
|
||||
expect(var->Value != 0, label);
|
||||
if (var->Value != 0) {
|
||||
expect(gen_str_contains(var->Value->Content, gen_txt("GENCPP_BASELINE")), label);
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
gen_Context ctx = {0};
|
||||
gen_init(& ctx);
|
||||
gen_Context ctx = {0}; gen_init(&ctx);
|
||||
|
||||
gen_Builder src_hello = gen_builder_open("gen/hello.c");
|
||||
gen_CodeVar hello_var = gen_parse_variable(code(
|
||||
char const* hello_gencpp_str = "HELLO GENCPP C11 !";
|
||||
));
|
||||
gen_builder_print( & src_hello, hello_var );
|
||||
gen_builder_write(& src_hello);
|
||||
gen_CodeTypename type = gen_def_type(name(char), .specifiers = gen_def_specifiers(2, Spec_Const, Spec_Ptr) );
|
||||
gen_CodeVar upfront = gen_def_variable(type, name(baseline_message),
|
||||
.value = gen_untyped_str(code("\"GENCPP_BASELINE\""))
|
||||
);
|
||||
expect_variable(upfront, gen_txt("c11 upfront"));
|
||||
expect_fragments(gen_strbuilder_to_str(gen_code_to_strbuilder(upfront)), gen_txt("c11 upfront serialized"));
|
||||
|
||||
gen_CodeBody body = gen_parse_file("gen/hello.c");
|
||||
for (gen_Code code = gen_iterator(CodeBody, body, code)) switch (code->Type) {
|
||||
case CT_Variable:
|
||||
gen_CodeVar var = (gen_CodeVar) code;
|
||||
gen_log_fmt("%S", var->Value);
|
||||
break;
|
||||
}
|
||||
gen_Code untyped = gen_code_str(char const* baseline_message = "GENCPP_BASELINE"; );
|
||||
expect(untyped != 0, gen_txt("c11 untyped"));
|
||||
|
||||
gen_deinit(& ctx);
|
||||
gen_Str untyped_text = gen_strbuilder_to_str(gen_code_to_strbuilder(untyped));
|
||||
expect_fragments(untyped_text, gen_txt("c11 untyped content"));
|
||||
expect_variable(gen_parse_variable(untyped_text), gen_txt("c11 untyped reparsed"));
|
||||
|
||||
gen_CodeVar parsed = gen_parse_variable(code(char const* baseline_message = "GENCPP_BASELINE"; ));
|
||||
expect_variable(parsed, gen_txt("c11 parsed"));
|
||||
expect_fragments(gen_strbuilder_to_str(gen_code_to_strbuilder(parsed)), gen_txt("c11 parsed serialized"));
|
||||
|
||||
gen_deinit(&ctx);
|
||||
if (g_failures != 0) { gen_log_fmt("c11 baseline smoke failed: %d\n", g_failures); return 1; }
|
||||
gen_log_fmt("c11 baseline smoke passed\n");
|
||||
return 0;
|
||||
}
|
||||
+44
-16
@@ -3,27 +3,55 @@
|
||||
#define GEN_ENFORCE_STRONG_CODE_TYPES
|
||||
#include "gen.hpp"
|
||||
|
||||
global int g_failures = 0;
|
||||
|
||||
internal void expect(int condition, gen::Str name) {
|
||||
if (condition == false) { gen::log_fmt("FAIL %S\n", name); ++ g_failures; }
|
||||
}
|
||||
|
||||
internal void expect_fragments(gen::Str text, gen::Str label) {
|
||||
expect(text.Ptr != nullptr && text.Len > 0, label);
|
||||
expect(gen::str_contains(text, txt("baseline_message")), label);
|
||||
expect(gen::str_contains(text, txt("char")), label);
|
||||
expect(gen::str_contains(text, txt("const")), label);
|
||||
expect(gen::str_contains(text, txt("*")), label);
|
||||
expect(gen::str_contains(text, txt("GENCPP_BASELINE")), label);
|
||||
}
|
||||
|
||||
internal void expect_variable(gen::CodeVar var, gen::Str label) {
|
||||
expect(var.ast != nullptr, label); if (var.ast == nullptr) return;
|
||||
expect(var->Type == gen::CT_Variable, label);
|
||||
expect(gen::str_contains(var->Name, txt("baseline_message")), label);
|
||||
expect(var->ValueType.ast != nullptr, label);
|
||||
expect(var->Value.ast != nullptr, label);
|
||||
if (var->Value.ast != nullptr) {
|
||||
expect(gen::str_contains(var->Value->Content, txt("GENCPP_BASELINE")), label);
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace gen;
|
||||
Context ctx = {};
|
||||
gen::init( & ctx);
|
||||
Context ctx = {}; init(&ctx);
|
||||
|
||||
Builder src_hello = builder_open("gen/hello.cpp");
|
||||
CodeVar hello_var = parse_variable( code(
|
||||
constexpr char const* hello_gencpp_str = "HELLO GENCPP !";
|
||||
));
|
||||
src_hello.print(hello_var);
|
||||
src_hello.write();
|
||||
Opts_def_type type_opts = {};
|
||||
type_opts.specifiers = def_specifiers(args(Spec_Const, Spec_Ptr));
|
||||
CodeTypename type = def_type(name(char), type_opts);
|
||||
Opts_def_variable opts = {}; opts.value = untyped_str(code("\"GENCPP_BASELINE\""));
|
||||
CodeVar upfront = def_variable(type, name(baseline_message), opts);
|
||||
expect_variable(upfront, txt("cpp upfront"));
|
||||
expect_fragments(strbuilder_to_str(code_to_strbuilder((Code)upfront)), txt("cpp upfront serialized"));
|
||||
|
||||
CodeBody body = parse_file("gen/hello.cpp");
|
||||
for ( Code code : body ) switch (code->Type) {
|
||||
case CT_Variable:
|
||||
CodeVar var = cast(CodeVar, code);
|
||||
log_fmt("%S", var->Value);
|
||||
break;
|
||||
}
|
||||
Code untyped = code_str(char const* baseline_message = "GENCPP_BASELINE";); expect(untyped.ast != nullptr, txt("cpp untyped"));
|
||||
Str untyped_text = strbuilder_to_str(code_to_strbuilder(untyped)); expect_fragments(untyped_text, txt("cpp untyped content"));
|
||||
CodeVar parsed_untyped = parse_variable(untyped_text); expect_variable(parsed_untyped, txt("cpp untyped reparsed"));
|
||||
|
||||
gen::deinit(& ctx);
|
||||
CodeVar parsed = parse_variable(code(char const* baseline_message = "GENCPP_BASELINE"; ));
|
||||
expect_variable(parsed, txt("cpp parsed"));
|
||||
expect_fragments(strbuilder_to_str(code_to_strbuilder((Code)parsed)), txt("cpp parsed serialized"));
|
||||
|
||||
deinit(&ctx);
|
||||
if (g_failures != 0) { log_fmt("cpp baseline smoke failed: %d\n", g_failures); return 1; }
|
||||
log_fmt("cpp baseline smoke passed\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
#define GEN_IMPLEMENTATION
|
||||
#define GEN_DEFINE_LIBRARY_CODE_CONSTANTS
|
||||
#define GEN_ENFORCE_STRONG_CODE_TYPES
|
||||
#include "gen.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
gen::log_fmt("FAIL forced assertion\n");
|
||||
return 1;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
int main( {
|
||||
return 1;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
@echo off
|
||||
exit /b 1
|
||||
@@ -0,0 +1,7 @@
|
||||
extern "C" void baseline_missing_link_target(void);
|
||||
|
||||
int main()
|
||||
{
|
||||
baseline_missing_link_target();
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
int main(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
int main(void)
|
||||
{
|
||||
return 73;
|
||||
}
|
||||
Reference in new issue
Block a user