mirror of
https://github.com/Ed94/gencpp.git
synced 2024-12-21 23:34:44 -08:00
Updates to test and workspace
Added a more granular test using the original library files. Already helped me identify a bug.
This commit is contained in:
parent
9d27c7d37e
commit
3319bfcaa9
1
.gitignore
vendored
1
.gitignore
vendored
@ -28,3 +28,4 @@ release/**
|
||||
**/Unreal/*.cpp
|
||||
! **/Unreal/validate.unreal.cpp
|
||||
project/auxillary/vis_ast/dependencies/temp
|
||||
test/gen/original
|
||||
|
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -36,7 +36,8 @@
|
||||
"mmsystem.h": "c",
|
||||
"propidl.h": "c",
|
||||
"android_native_app_glue.h": "c",
|
||||
"raylib.h": "c"
|
||||
"raylib.h": "c",
|
||||
"*.m": "cpp"
|
||||
},
|
||||
"C_Cpp.intelliSenseEngineFallback": "disabled",
|
||||
"mesonbuild.configureOnOpen": true,
|
||||
|
@ -43,6 +43,7 @@
|
||||
<Define>GEN_TIME</Define>
|
||||
<Define>GEN_SYSTEM_WINDOWS</Define>
|
||||
<Define>GEN_INTELLISENSE_DIRECTIVES</Define>
|
||||
<Define>GEN_EXECUTION_EXPRESSION_SUPPORT</Define>
|
||||
</Defines>
|
||||
<ConfigProperties>
|
||||
<ConfigAndPlatform>
|
||||
|
@ -164,9 +164,13 @@ if ( $singleheader )
|
||||
|
||||
if ( $test )
|
||||
{
|
||||
$path_gen = join-path $path_test gen
|
||||
$path_gen_build = join-path $path_gen build
|
||||
$path_build = join-path $path_test build
|
||||
$path_gen = join-path $path_test gen
|
||||
$path_gen_build = join-path $path_gen build
|
||||
$path_build = join-path $path_test build
|
||||
$path_original = join-path $path_gen original
|
||||
$path_components = join-path $path_original components
|
||||
$path_dependencies = join-path $path_original dependencies
|
||||
$path_helpers = join-path $path_original helpers
|
||||
|
||||
if ( -not(Test-Path($path_build) )) {
|
||||
New-Item -ItemType Directory -Path $path_build
|
||||
@ -177,6 +181,18 @@ if ( $test )
|
||||
if ( -not(Test-Path($path_gen_build) )) {
|
||||
New-Item -ItemType Directory -Path $path_gen_build
|
||||
}
|
||||
if ( -not(test-path $path_original)) {
|
||||
new-item -ItemType Directory -Path $path_original
|
||||
}
|
||||
if ( -not(test-path $path_components)) {
|
||||
new-item -ItemType Directory -Path $path_components
|
||||
}
|
||||
if ( -not(test-path $path_dependencies)) {
|
||||
new-item -ItemType Directory -Path $path_dependencies
|
||||
}
|
||||
if ( -not(test-path $path_helpers)) {
|
||||
new-item -ItemType Directory -Path $path_helpers
|
||||
}
|
||||
|
||||
$path_bootstrap = join-path $path_project gen
|
||||
|
||||
|
@ -671,11 +671,11 @@
|
||||
</Expand>
|
||||
</Type>
|
||||
|
||||
<Type Name="gen::Parser::Token">
|
||||
<Type Name="gen::parser::Token">
|
||||
<DisplayString>Length:{Length} Text:{Text, [Length]s} Type:{Type}</DisplayString>
|
||||
</Type>
|
||||
|
||||
<Type Name="gen::Parser::TokArray">
|
||||
<Type Name="gen::parser::TokArray">
|
||||
<DisplayString>Current[ { Arr[Idx] } ] Idx:{ Idx }</DisplayString>
|
||||
</Type>
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <functional>
|
||||
#include <tuple>
|
||||
|
||||
class MyClass;
|
||||
|
||||
@ -24,12 +25,20 @@ struct TemplateStruct<int, 10> {
|
||||
int specialMember[10];
|
||||
};
|
||||
|
||||
typedef decltype(nullptr) (MyClass::*InsaneComplexTypeDef)(
|
||||
decltype((MyEnum::VAL1 == MyEnum::VAL2) ? 1 : 2.0)
|
||||
(TemplateStruct<decltype(OuterStruct().unionInstance.inner), 5>::*ptr)[5][alignof(double)],
|
||||
std::function<void *(TemplateStruct<int, 10>&&,
|
||||
void (MyClass::*memFnPtr)(TemplateStruct<decltype(OuterStruct().unionInstance.inner)>))>,
|
||||
template<typename T>
|
||||
struct AnotherTemplate {
|
||||
T value;
|
||||
};
|
||||
|
||||
typedef decltype(nullptr) (MyClass::*InsaneComplexTypeDef)
|
||||
(
|
||||
decltype((MyEnum::VAL1 == MyEnum::VAL2) ? 1 : 2.0)(TemplateStruct<decltype(OuterStruct().unionInstance.inner), 5>::*ptr)[5][alignof(double)],
|
||||
std::function<void *(TemplateStruct<int, 10>&&, void (MyClass::*memFnPtr)(TemplateStruct<decltype(OuterStruct().unionInstance.inner)>))>,
|
||||
int (MyClass::*&refToMemFnPtr)(TemplateStruct<int, 10>),
|
||||
int (TemplateStruct<int, 10>::*memberPointer)[10],
|
||||
char&&...
|
||||
) volatile const && noexcept;
|
||||
typename std::tuple_element<0, std::tuple<AnotherTemplate<TemplateStruct<decltype(OuterStruct().unionInstance), 3>>>>::type::*complexMember,
|
||||
template<typename U> typename AnotherTemplate<U>::*templateMember
|
||||
char&&...,
|
||||
)
|
||||
volatile const && noexcept;
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "gen.builder.cpp"
|
||||
#include "sanity.cpp"
|
||||
#include "SOA.cpp"
|
||||
#include "validate.original.cpp"
|
||||
#include "validate.singleheader.cpp"
|
||||
|
||||
int gen_main()
|
||||
@ -18,7 +19,9 @@ int gen_main()
|
||||
|
||||
// check_SOA();
|
||||
|
||||
check_singleheader_ast();
|
||||
validate_original_files_ast();
|
||||
validate_singleheader_ast();
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
159
test/validate.original.cpp
Normal file
159
test/validate.original.cpp
Normal file
@ -0,0 +1,159 @@
|
||||
|
||||
#define GEN_DEFINE_LIBRARY_CODE_CONSTANTS
|
||||
#define GEN_ENFORCE_STRONG_CODE_TYPES
|
||||
#define GEN_EXPOSE_BACKEND
|
||||
#define GEN_BENCHMARK
|
||||
#include "gen.hpp"
|
||||
#include "gen.builder.hpp"
|
||||
#include "gen.scanner.hpp"
|
||||
using namespace gen;
|
||||
|
||||
#ifdef GEN_SYSTEM_WINDOWS
|
||||
#include <process.h>
|
||||
#endif
|
||||
|
||||
#define path_root "../"
|
||||
#define path_project path_root "project/"
|
||||
#define path_scripts path_root "scripts/"
|
||||
#define path_components path_project "components/"
|
||||
#define path_generated path_components "gen/"
|
||||
#define path_dependencies path_project "dependencies/"
|
||||
#define path_helpers path_project "helpers/"
|
||||
|
||||
void validate_file_ast( char const* path, char const* path_gen )
|
||||
{
|
||||
log_fmt( "\nValidating: %s", path );
|
||||
|
||||
FileContents file = file_read_contents( GlobalAllocator, true, path );
|
||||
u64 time_start = time_rel_ms();
|
||||
CodeBody ast = parse_global_body( { file.size, (char const*)file.data } );
|
||||
log_fmt("\n\tAst generated. Time taken: %llu ms", time_rel_ms() - time_start);
|
||||
|
||||
log_fmt("\n\tSerializng ast:\n");
|
||||
time_start = time_rel_ms();
|
||||
Builder
|
||||
builder = Builder::open( path_gen );
|
||||
builder.print( ast );
|
||||
builder.write();
|
||||
log_fmt("\tSerialized. Time taken: %llu ms", time_rel_ms() - time_start);
|
||||
|
||||
// Need to execute clang format on the generated file to get it to match the original.
|
||||
#define clang_format "clang-format "
|
||||
#define cf_format_inplace "-i "
|
||||
#define cf_style "-style=file:" "C:/projects/gencpp/scripts/.clang-format "
|
||||
#define cf_verbose "-verbose "
|
||||
String command = String::make( GlobalAllocator, clang_format );
|
||||
command.append( cf_format_inplace );
|
||||
command.append( cf_style );
|
||||
command.append( cf_verbose );
|
||||
command.append( path_gen );
|
||||
log_fmt("\n\tRunning clang-format on generated file:\n");
|
||||
system( command );
|
||||
log_fmt("\tclang-format finished reformatting.");
|
||||
#undef cf_cmd
|
||||
#undef cf_format_inplace
|
||||
#undef cf_style
|
||||
#undef cf_verbse
|
||||
|
||||
FileContents file_gen = file_read_contents( GlobalAllocator, true, path_gen );
|
||||
log_fmt("\n\tReconstructing from generated file:");
|
||||
time_start = time_rel_ms();
|
||||
CodeBody ast_gen = parse_global_body( { file_gen.size, (char const*)file_gen.data } );
|
||||
log_fmt("\n\tAst generated. Time taken: %llu ms", time_rel_ms() - time_start);
|
||||
|
||||
time_start = time_rel_ms();
|
||||
|
||||
if ( ast.is_equal( ast_gen ) )
|
||||
log_fmt( "\n\tPassed!: AST passed validation! " );
|
||||
else
|
||||
log_fmt( "\nFailed: AST did not pass validation " );
|
||||
|
||||
log_fmt( "Time taken: %llu ms\n", time_rel_ms() - time_start );
|
||||
}
|
||||
|
||||
void validate_original_files_ast()
|
||||
{
|
||||
gen::init();
|
||||
log_fmt("\nvalidate_original_files_ast:\n");
|
||||
|
||||
PreprocessorDefines.append( get_cached_string( txt("GEN_DEF_INLINE") ));
|
||||
PreprocessorDefines.append( get_cached_string( txt("GEN_IMPL_INLINE") ));
|
||||
|
||||
// Helpers
|
||||
{
|
||||
#define validate( path ) validate_file_ast( path_helpers path, "gen/original/helpers/" path );
|
||||
validate( "push_ignores.inline.hpp" );
|
||||
validate( "pop_ignores.inline.hpp" );
|
||||
#undef validate
|
||||
}
|
||||
|
||||
// Dependencies
|
||||
{
|
||||
#define validate( path ) validate_file_ast( path_dependencies path, "gen/original/dependencies/" path )
|
||||
validate( "header_start.hpp" );
|
||||
validate( "macros.hpp" );
|
||||
validate( "basic_types.hpp" );
|
||||
validate( "debug.hpp" );
|
||||
validate( "memory.hpp" );
|
||||
validate( "string_ops.hpp" );
|
||||
validate( "printing.hpp" );
|
||||
validate( "containers.hpp" );
|
||||
validate( "hashing.hpp" );
|
||||
validate( "strings.hpp" );
|
||||
validate( "filesystem.hpp" );
|
||||
validate( "timing.hpp" );
|
||||
|
||||
validate( "src_start.cpp" );
|
||||
validate( "debug.cpp" );
|
||||
validate( "string_ops.cpp" );
|
||||
validate( "printing.cpp" );
|
||||
validate( "memory.cpp" );
|
||||
validate( "hashing.cpp" );
|
||||
validate( "strings.cpp" );
|
||||
validate( "filesystem.cpp" );
|
||||
validate( "timing.cpp" );
|
||||
|
||||
validate( "parsing.cpp" );
|
||||
validate( "parisng.hpp" );
|
||||
#undef validate
|
||||
}
|
||||
|
||||
// Components
|
||||
{
|
||||
#define validate( path ) validate_file_ast( path_components path, "gen/original/components/" path )
|
||||
validate( "header_start.hpp" );
|
||||
validate( "types.hpp" );
|
||||
validate( "gen/ecode.hpp" );
|
||||
validate( "gen/eoperator.hpp" );
|
||||
validate( "gen/especifier.hpp" );
|
||||
validate( "ast.hpp" );
|
||||
validate( "code_types.hpp" );
|
||||
validate( "ast_types.hpp" );
|
||||
validate( "interface.hpp" );
|
||||
validate( "inlines.hpp" );
|
||||
validate( "gen/ast_inlines.hpp" );
|
||||
validate( "header_end.hpp" );
|
||||
|
||||
validate( "static_data.cpp" );
|
||||
validate( "ast_case_macros.cpp" );
|
||||
validate( "ast.cpp" );
|
||||
validate( "code_serialization.cpp" );
|
||||
validate( "interface.cpp" );
|
||||
validate( "interface.upfront.cpp" );
|
||||
validate( "gen/etoktype.cpp" );
|
||||
validate( "lexer.cpp" );
|
||||
validate( "parser.cpp" );
|
||||
validate( "interface.parsing.cpp" );
|
||||
validate( "interface.untyped.cpp" );
|
||||
#undef validate
|
||||
}
|
||||
|
||||
gen::deinit();
|
||||
}
|
||||
|
||||
#undef path_root
|
||||
#undef path_project
|
||||
#undef path_scripts
|
||||
#undef path_components
|
||||
#undef path_generated
|
||||
#undef path_dependencies
|
@ -11,11 +11,11 @@ using namespace gen;
|
||||
#include <process.h>
|
||||
#endif
|
||||
|
||||
void check_singleheader_ast()
|
||||
void validate_singleheader_ast()
|
||||
{
|
||||
#define root_dir "../"
|
||||
gen::init();
|
||||
log_fmt("\ncheck_singleheader_ast:\n");
|
||||
log_fmt("\validate_singleheader_ast:\n");
|
||||
|
||||
FileContents file = file_read_contents( GlobalAllocator, true, root_dir "singleheader/gen/gen.hpp" );
|
||||
u64 time_start = time_rel_ms();
|
||||
|
Loading…
Reference in New Issue
Block a user