├── .clang-format ├── .github └── workflows │ └── cmake.yml ├── .gitignore ├── Agents.MD ├── CMakeLists.txt ├── Docs.md ├── LICENSE ├── Lib └── Catch2 │ ├── .bazelrc │ ├── .clang-format │ ├── .conan │ ├── build.py │ └── test_package │ │ ├── CMakeLists.txt │ │ ├── conanfile.py │ │ └── test_package.cpp │ ├── .gitattributes │ ├── .gitignore │ ├── BUILD.bazel │ ├── CMake │ ├── Catch2Config.cmake.in │ ├── CatchConfigOptions.cmake │ ├── CatchMiscFunctions.cmake │ ├── FindGcov.cmake │ ├── FindLcov.cmake │ ├── Findcodecov.cmake │ ├── catch2-with-main.pc.in │ ├── catch2.pc.in │ └── llvm-cov-wrapper │ ├── CMakeLists.txt │ ├── CMakePresets.json │ ├── CODE_OF_CONDUCT.md │ ├── Doxyfile │ ├── LICENSE.txt │ ├── README.md │ ├── SECURITY.md │ ├── WORKSPACE │ ├── appveyor.yml │ ├── codecov.yml │ ├── conanfile.py │ ├── data │ └── artwork │ │ ├── catch2-c-logo.png │ │ ├── catch2-hand-logo.png │ │ └── catch2-logo-small.png │ ├── docs │ ├── Readme.md │ ├── assertions.md │ ├── benchmarks.md │ ├── ci-and-misc.md │ ├── cmake-integration.md │ ├── command-line.md │ ├── commercial-users.md │ ├── configuration.md │ ├── contributing.md │ ├── deprecations.md │ ├── event-listeners.md │ ├── faq.md │ ├── generators.md │ ├── limitations.md │ ├── list-of-examples.md │ ├── logging.md │ ├── matchers.md │ ├── migrate-v2-to-v3.md │ ├── opensource-users.md │ ├── other-macros.md │ ├── own-main.md │ ├── release-notes.md │ ├── release-process.md │ ├── reporter-events.md │ ├── reporters.md │ ├── test-cases-and-sections.md │ ├── test-fixtures.md │ ├── tostring.md │ ├── tutorial.md │ ├── usage-tips.md │ └── why-catch.md │ ├── examples │ ├── 010-TestCase.cpp │ ├── 020-TestCase-1.cpp │ ├── 020-TestCase-2.cpp │ ├── 030-Asn-Require-Check.cpp │ ├── 100-Fix-Section.cpp │ ├── 110-Fix-ClassFixture.cpp │ ├── 120-Bdd-ScenarioGivenWhenThen.cpp │ ├── 210-Evt-EventListeners.cpp │ ├── 231-Cfg-OutputStreams.cpp │ ├── 300-Gen-OwnGenerator.cpp │ ├── 301-Gen-MapTypeConversion.cpp │ ├── 302-Gen-Table.cpp │ ├── 310-Gen-VariablesInGenerators.cpp │ ├── 311-Gen-CustomCapture.cpp │ └── CMakeLists.txt │ ├── extras │ ├── Catch.cmake │ ├── CatchAddTests.cmake │ ├── CatchShardTests.cmake │ ├── CatchShardTestsImpl.cmake │ ├── ParseAndAddCatchTests.cmake │ ├── catch_amalgamated.cpp │ ├── catch_amalgamated.hpp │ ├── gdbinit │ └── lldbinit │ ├── fuzzing │ ├── CMakeLists.txt │ ├── NullOStream.cpp │ ├── NullOStream.h │ ├── build_fuzzers.sh │ ├── fuzz_TestSpecParser.cpp │ ├── fuzz_XmlWriter.cpp │ └── fuzz_textflow.cpp │ ├── mdsnippets.json │ ├── src │ ├── CMakeLists.txt │ └── catch2 │ │ ├── benchmark │ │ ├── catch_benchmark.hpp │ │ ├── catch_benchmark_all.hpp │ │ ├── catch_chronometer.cpp │ │ ├── catch_chronometer.hpp │ │ ├── catch_clock.hpp │ │ ├── catch_constructor.hpp │ │ ├── catch_environment.hpp │ │ ├── catch_estimate.hpp │ │ ├── catch_execution_plan.hpp │ │ ├── catch_optimizer.hpp │ │ ├── catch_outlier_classification.hpp │ │ ├── catch_sample_analysis.hpp │ │ └── detail │ │ │ ├── catch_analyse.hpp │ │ │ ├── catch_benchmark_function.cpp │ │ │ ├── catch_benchmark_function.hpp │ │ │ ├── catch_complete_invoke.hpp │ │ │ ├── catch_estimate_clock.hpp │ │ │ ├── catch_measure.hpp │ │ │ ├── catch_repeat.hpp │ │ │ ├── catch_run_for_at_least.cpp │ │ │ ├── catch_run_for_at_least.hpp │ │ │ ├── catch_stats.cpp │ │ │ ├── catch_stats.hpp │ │ │ └── catch_timing.hpp │ │ ├── catch_all.hpp │ │ ├── catch_approx.cpp │ │ ├── catch_approx.hpp │ │ ├── catch_assertion_info.hpp │ │ ├── catch_assertion_result.cpp │ │ ├── catch_assertion_result.hpp │ │ ├── catch_config.cpp │ │ ├── catch_config.hpp │ │ ├── catch_message.cpp │ │ ├── catch_message.hpp │ │ ├── catch_registry_hub.cpp │ │ ├── catch_section_info.hpp │ │ ├── catch_session.cpp │ │ ├── catch_session.hpp │ │ ├── catch_tag_alias.hpp │ │ ├── catch_tag_alias_autoregistrar.cpp │ │ ├── catch_tag_alias_autoregistrar.hpp │ │ ├── catch_template_test_macros.hpp │ │ ├── catch_test_case_info.cpp │ │ ├── catch_test_case_info.hpp │ │ ├── catch_test_macros.hpp │ │ ├── catch_test_spec.cpp │ │ ├── catch_test_spec.hpp │ │ ├── catch_timer.cpp │ │ ├── catch_timer.hpp │ │ ├── catch_tostring.cpp │ │ ├── catch_tostring.hpp │ │ ├── catch_totals.cpp │ │ ├── catch_totals.hpp │ │ ├── catch_translate_exception.hpp │ │ ├── catch_user_config.hpp.in │ │ ├── catch_version.cpp │ │ ├── catch_version.hpp │ │ ├── catch_version_macros.hpp │ │ ├── generators │ │ ├── catch_generator_exception.cpp │ │ ├── catch_generator_exception.hpp │ │ ├── catch_generators.cpp │ │ ├── catch_generators.hpp │ │ ├── catch_generators_adapters.hpp │ │ ├── catch_generators_all.hpp │ │ ├── catch_generators_random.cpp │ │ ├── catch_generators_random.hpp │ │ └── catch_generators_range.hpp │ │ ├── interfaces │ │ ├── catch_interfaces_all.hpp │ │ ├── catch_interfaces_capture.cpp │ │ ├── catch_interfaces_capture.hpp │ │ ├── catch_interfaces_config.cpp │ │ ├── catch_interfaces_config.hpp │ │ ├── catch_interfaces_enum_values_registry.hpp │ │ ├── catch_interfaces_exception.cpp │ │ ├── catch_interfaces_exception.hpp │ │ ├── catch_interfaces_generatortracker.cpp │ │ ├── catch_interfaces_generatortracker.hpp │ │ ├── catch_interfaces_registry_hub.cpp │ │ ├── catch_interfaces_registry_hub.hpp │ │ ├── catch_interfaces_reporter.cpp │ │ ├── catch_interfaces_reporter.hpp │ │ ├── catch_interfaces_reporter_factory.cpp │ │ ├── catch_interfaces_reporter_factory.hpp │ │ ├── catch_interfaces_reporter_registry.cpp │ │ ├── catch_interfaces_reporter_registry.hpp │ │ ├── catch_interfaces_tag_alias_registry.hpp │ │ ├── catch_interfaces_testcase.cpp │ │ └── catch_interfaces_testcase.hpp │ │ ├── internal │ │ ├── catch_assertion_handler.cpp │ │ ├── catch_assertion_handler.hpp │ │ ├── catch_case_insensitive_comparisons.cpp │ │ ├── catch_case_insensitive_comparisons.hpp │ │ ├── catch_case_sensitive.hpp │ │ ├── catch_clara.cpp │ │ ├── catch_clara.hpp │ │ ├── catch_commandline.cpp │ │ ├── catch_commandline.hpp │ │ ├── catch_compiler_capabilities.hpp │ │ ├── catch_config_android_logwrite.hpp │ │ ├── catch_config_counter.hpp │ │ ├── catch_config_uncaught_exceptions.hpp │ │ ├── catch_config_wchar.hpp │ │ ├── catch_console_colour.cpp │ │ ├── catch_console_colour.hpp │ │ ├── catch_console_width.hpp │ │ ├── catch_container_nonmembers.hpp │ │ ├── catch_context.cpp │ │ ├── catch_context.hpp │ │ ├── catch_debug_console.cpp │ │ ├── catch_debug_console.hpp │ │ ├── catch_debugger.cpp │ │ ├── catch_debugger.hpp │ │ ├── catch_decomposer.cpp │ │ ├── catch_decomposer.hpp │ │ ├── catch_enforce.cpp │ │ ├── catch_enforce.hpp │ │ ├── catch_enum_values_registry.cpp │ │ ├── catch_enum_values_registry.hpp │ │ ├── catch_errno_guard.cpp │ │ ├── catch_errno_guard.hpp │ │ ├── catch_exception_translator_registry.cpp │ │ ├── catch_exception_translator_registry.hpp │ │ ├── catch_fatal_condition_handler.cpp │ │ ├── catch_fatal_condition_handler.hpp │ │ ├── catch_floating_point_helpers.cpp │ │ ├── catch_floating_point_helpers.hpp │ │ ├── catch_istream.cpp │ │ ├── catch_istream.hpp │ │ ├── catch_lazy_expr.cpp │ │ ├── catch_lazy_expr.hpp │ │ ├── catch_leak_detector.cpp │ │ ├── catch_leak_detector.hpp │ │ ├── catch_list.cpp │ │ ├── catch_list.hpp │ │ ├── catch_main.cpp │ │ ├── catch_message_info.cpp │ │ ├── catch_message_info.hpp │ │ ├── catch_meta.hpp │ │ ├── catch_move_and_forward.hpp │ │ ├── catch_noncopyable.hpp │ │ ├── catch_optional.hpp │ │ ├── catch_output_redirect.cpp │ │ ├── catch_output_redirect.hpp │ │ ├── catch_platform.hpp │ │ ├── catch_polyfills.cpp │ │ ├── catch_polyfills.hpp │ │ ├── catch_preprocessor.hpp │ │ ├── catch_preprocessor_remove_parens.hpp │ │ ├── catch_random_number_generator.cpp │ │ ├── catch_random_number_generator.hpp │ │ ├── catch_random_seed_generation.cpp │ │ ├── catch_random_seed_generation.hpp │ │ ├── catch_reporter_registry.cpp │ │ ├── catch_reporter_registry.hpp │ │ ├── catch_reporter_spec_parser.cpp │ │ ├── catch_reporter_spec_parser.hpp │ │ ├── catch_result_type.cpp │ │ ├── catch_result_type.hpp │ │ ├── catch_reusable_string_stream.cpp │ │ ├── catch_reusable_string_stream.hpp │ │ ├── catch_run_context.cpp │ │ ├── catch_run_context.hpp │ │ ├── catch_section.cpp │ │ ├── catch_section.hpp │ │ ├── catch_sharding.hpp │ │ ├── catch_singletons.cpp │ │ ├── catch_singletons.hpp │ │ ├── catch_source_line_info.cpp │ │ ├── catch_source_line_info.hpp │ │ ├── catch_startup_exception_registry.cpp │ │ ├── catch_startup_exception_registry.hpp │ │ ├── catch_stdstreams.cpp │ │ ├── catch_stdstreams.hpp │ │ ├── catch_stream_end_stop.hpp │ │ ├── catch_string_manip.cpp │ │ ├── catch_string_manip.hpp │ │ ├── catch_stringref.cpp │ │ ├── catch_stringref.hpp │ │ ├── catch_tag_alias_registry.cpp │ │ ├── catch_tag_alias_registry.hpp │ │ ├── catch_template_test_registry.hpp │ │ ├── catch_test_case_info_hasher.cpp │ │ ├── catch_test_case_info_hasher.hpp │ │ ├── catch_test_case_registry_impl.cpp │ │ ├── catch_test_case_registry_impl.hpp │ │ ├── catch_test_case_tracker.cpp │ │ ├── catch_test_case_tracker.hpp │ │ ├── catch_test_failure_exception.hpp │ │ ├── catch_test_macro_impl.hpp │ │ ├── catch_test_registry.cpp │ │ ├── catch_test_registry.hpp │ │ ├── catch_test_spec_parser.cpp │ │ ├── catch_test_spec_parser.hpp │ │ ├── catch_textflow.cpp │ │ ├── catch_textflow.hpp │ │ ├── catch_to_string.hpp │ │ ├── catch_uncaught_exceptions.cpp │ │ ├── catch_uncaught_exceptions.hpp │ │ ├── catch_unique_name.hpp │ │ ├── catch_unique_ptr.hpp │ │ ├── catch_void_type.hpp │ │ ├── catch_wildcard_pattern.cpp │ │ ├── catch_wildcard_pattern.hpp │ │ ├── catch_windows_h_proxy.hpp │ │ ├── catch_xmlwriter.cpp │ │ └── catch_xmlwriter.hpp │ │ ├── matchers │ │ ├── catch_matchers.cpp │ │ ├── catch_matchers.hpp │ │ ├── catch_matchers_all.hpp │ │ ├── catch_matchers_container_properties.cpp │ │ ├── catch_matchers_container_properties.hpp │ │ ├── catch_matchers_contains.hpp │ │ ├── catch_matchers_exception.cpp │ │ ├── catch_matchers_exception.hpp │ │ ├── catch_matchers_floating_point.cpp │ │ ├── catch_matchers_floating_point.hpp │ │ ├── catch_matchers_predicate.cpp │ │ ├── catch_matchers_predicate.hpp │ │ ├── catch_matchers_quantifiers.cpp │ │ ├── catch_matchers_quantifiers.hpp │ │ ├── catch_matchers_string.cpp │ │ ├── catch_matchers_string.hpp │ │ ├── catch_matchers_templated.cpp │ │ ├── catch_matchers_templated.hpp │ │ ├── catch_matchers_vector.hpp │ │ └── internal │ │ │ ├── catch_matchers_impl.cpp │ │ │ └── catch_matchers_impl.hpp │ │ └── reporters │ │ ├── catch_reporter_automake.cpp │ │ ├── catch_reporter_automake.hpp │ │ ├── catch_reporter_common_base.cpp │ │ ├── catch_reporter_common_base.hpp │ │ ├── catch_reporter_compact.cpp │ │ ├── catch_reporter_compact.hpp │ │ ├── catch_reporter_console.cpp │ │ ├── catch_reporter_console.hpp │ │ ├── catch_reporter_cumulative_base.cpp │ │ ├── catch_reporter_cumulative_base.hpp │ │ ├── catch_reporter_event_listener.cpp │ │ ├── catch_reporter_event_listener.hpp │ │ ├── catch_reporter_helpers.cpp │ │ ├── catch_reporter_helpers.hpp │ │ ├── catch_reporter_junit.cpp │ │ ├── catch_reporter_junit.hpp │ │ ├── catch_reporter_multi.cpp │ │ ├── catch_reporter_multi.hpp │ │ ├── catch_reporter_registrars.cpp │ │ ├── catch_reporter_registrars.hpp │ │ ├── catch_reporter_sonarqube.cpp │ │ ├── catch_reporter_sonarqube.hpp │ │ ├── catch_reporter_streaming_base.cpp │ │ ├── catch_reporter_streaming_base.hpp │ │ ├── catch_reporter_tap.cpp │ │ ├── catch_reporter_tap.hpp │ │ ├── catch_reporter_teamcity.cpp │ │ ├── catch_reporter_teamcity.hpp │ │ ├── catch_reporter_xml.cpp │ │ ├── catch_reporter_xml.hpp │ │ └── catch_reporters_all.hpp │ ├── tests │ ├── CMakeLists.txt │ ├── ExtraTests │ │ ├── CMakeLists.txt │ │ ├── ToDo.txt │ │ ├── X01-PrefixedMacros.cpp │ │ ├── X02-DisabledMacros.cpp │ │ ├── X03-DisabledExceptions-DefaultHandler.cpp │ │ ├── X04-DisabledExceptions-CustomHandler.cpp │ │ ├── X05-DeferredStaticChecks.cpp │ │ ├── X10-FallbackStringifier.cpp │ │ ├── X11-DisableStringification.cpp │ │ ├── X12-CustomDebugBreakMacro.cpp │ │ ├── X21-PartialTestCaseEvents.cpp │ │ ├── X22-BenchmarksInCumulativeReporter.cpp │ │ ├── X23-CasingInReporterNames.cpp │ │ ├── X24-ListenerStdoutCaptureInMultireporter.cpp │ │ ├── X25-ListenerCanAskForCapturedStdout.cpp │ │ ├── X26-ReporterPreferencesForPassingAssertionsIsRespected.cpp │ │ ├── X27-CapturedStdoutInTestCaseEvents.cpp │ │ ├── X28-ListenersGetEventsBeforeReporters.cpp │ │ ├── X29-CustomArgumentsForReporters.cpp │ │ ├── X30-BazelReporter.cpp │ │ ├── X31-DuplicatedTestCases.cpp │ │ ├── X32-DuplicatedTestCasesDifferentTags.cpp │ │ ├── X33-DuplicatedTestCaseMethods.cpp │ │ ├── X34-DuplicatedTestCaseMethodsDifferentFixtures.cpp │ │ ├── X35-DuplicatedReporterNames.cpp │ │ ├── X90-WindowsHeaderInclusion.cpp │ │ ├── X91-AmalgamatedCatch.cpp │ │ └── X92-NoTests.cpp │ ├── SelfTest │ │ ├── Baselines │ │ │ ├── automake.std.approved.txt │ │ │ ├── automake.sw.approved.txt │ │ │ ├── automake.sw.multi.approved.txt │ │ │ ├── compact.sw.approved.txt │ │ │ ├── compact.sw.multi.approved.txt │ │ │ ├── console.std.approved.txt │ │ │ ├── console.sw.approved.txt │ │ │ ├── console.sw.multi.approved.txt │ │ │ ├── console.swa4.approved.txt │ │ │ ├── default.sw.multi.approved.txt │ │ │ ├── junit.sw.approved.txt │ │ │ ├── junit.sw.multi.approved.txt │ │ │ ├── sonarqube.sw.approved.txt │ │ │ ├── sonarqube.sw.multi.approved.txt │ │ │ ├── tap.sw.approved.txt │ │ │ ├── tap.sw.multi.approved.txt │ │ │ ├── teamcity.sw.approved.txt │ │ │ ├── teamcity.sw.multi.approved.txt │ │ │ ├── xml.sw.approved.txt │ │ │ └── xml.sw.multi.approved.txt │ │ ├── IntrospectiveTests │ │ │ ├── Clara.tests.cpp │ │ │ ├── CmdLine.tests.cpp │ │ │ ├── CmdLineHelpers.tests.cpp │ │ │ ├── ColourImpl.tests.cpp │ │ │ ├── Details.tests.cpp │ │ │ ├── FloatingPoint.tests.cpp │ │ │ ├── GeneratorsImpl.tests.cpp │ │ │ ├── InternalBenchmark.tests.cpp │ │ │ ├── PartTracker.tests.cpp │ │ │ ├── RandomNumberGeneration.tests.cpp │ │ │ ├── Reporters.tests.cpp │ │ │ ├── Sharding.tests.cpp │ │ │ ├── Stream.tests.cpp │ │ │ ├── String.tests.cpp │ │ │ ├── StringManip.tests.cpp │ │ │ ├── Tag.tests.cpp │ │ │ ├── TestCaseInfoHasher.tests.cpp │ │ │ ├── TestSpecParser.tests.cpp │ │ │ ├── TextFlow.tests.cpp │ │ │ ├── ToString.tests.cpp │ │ │ ├── UniquePtr.tests.cpp │ │ │ └── Xml.tests.cpp │ │ ├── Misc │ │ │ ├── invalid-test-names.input │ │ │ ├── plain-old-tests.input │ │ │ └── special-characters-in-file.input │ │ ├── TestRegistrations.cpp │ │ ├── TimingTests │ │ │ └── Sleep.tests.cpp │ │ └── UsageTests │ │ │ ├── Approx.tests.cpp │ │ │ ├── BDD.tests.cpp │ │ │ ├── Benchmark.tests.cpp │ │ │ ├── Class.tests.cpp │ │ │ ├── Compilation.tests.cpp │ │ │ ├── Condition.tests.cpp │ │ │ ├── Decomposition.tests.cpp │ │ │ ├── EnumToString.tests.cpp │ │ │ ├── Exception.tests.cpp │ │ │ ├── Generators.tests.cpp │ │ │ ├── Matchers.tests.cpp │ │ │ ├── MatchersRanges.tests.cpp │ │ │ ├── Message.tests.cpp │ │ │ ├── Misc.tests.cpp │ │ │ ├── ToStringByte.tests.cpp │ │ │ ├── ToStringChrono.tests.cpp │ │ │ ├── ToStringGeneral.tests.cpp │ │ │ ├── ToStringOptional.tests.cpp │ │ │ ├── ToStringPair.tests.cpp │ │ │ ├── ToStringTuple.tests.cpp │ │ │ ├── ToStringVariant.tests.cpp │ │ │ ├── ToStringVector.tests.cpp │ │ │ ├── ToStringWhich.tests.cpp │ │ │ ├── Tricky.tests.cpp │ │ │ └── VariadicMacros.tests.cpp │ └── TestScripts │ │ ├── ConfigureTestsCommon.py │ │ ├── testBazelReporter.py │ │ ├── testConfigureDefaultReporter.py │ │ ├── testConfigureDisable.py │ │ ├── testConfigureDisableStringification.py │ │ ├── testConfigureExperimentalRedirect.py │ │ ├── testPartialTestCaseEvent.py │ │ ├── testRandomOrder.py │ │ └── testSharding.py │ ├── third_party │ └── clara.hpp │ └── tools │ ├── misc │ ├── CMakeLists.txt │ ├── appveyorBuildConfigurationScript.bat │ ├── appveyorMergeCoverageScript.py │ ├── appveyorTestRunScript.bat │ ├── coverage-helper.cpp │ └── installOpenCppCoverage.ps1 │ └── scripts │ ├── approvalTests.py │ ├── approve.py │ ├── buildAndTest.cmd │ ├── buildAndTest.sh │ ├── checkConvenienceHeaders.py │ ├── checkDuplicateFilenames.py │ ├── checkLicense.py │ ├── developBuild.py │ ├── extractFeaturesFromReleaseNotes.py │ ├── fixWhitespace.py │ ├── generateAmalgamatedFiles.py │ ├── majorRelease.py │ ├── minorRelease.py │ ├── patchRelease.py │ ├── releaseCommon.py │ ├── scriptCommon.py │ ├── updateDocumentSnippets.py │ └── updateDocumentToC.py ├── README.md ├── aflat.cfg ├── coverage.sh ├── ebnf.egnf ├── first-steps.MD ├── format-all.sh ├── include ├── ASM.hpp ├── CodeGenerator │ ├── CodeGenerator.hpp │ ├── Expr.hpp │ ├── GenerationResult.hpp │ ├── MockCodeGenerator.hpp │ ├── ScopeManager.hpp │ └── Utils.hpp ├── CompilerUtils.hpp ├── Configs.hpp ├── ErrorReporter.hpp ├── Exceptions.hpp ├── HashMap.hpp ├── LinkedList.hpp ├── LinkedListS.hpp ├── Parser │ ├── AST.hpp │ ├── AST │ │ ├── Statements.hpp │ │ └── Statements │ │ │ ├── Assign.hpp │ │ │ ├── Break.hpp │ │ │ ├── Call.hpp │ │ │ ├── Class.hpp │ │ │ ├── Continue.hpp │ │ │ ├── Dec.hpp │ │ │ ├── DecArr.hpp │ │ │ ├── DecAssign.hpp │ │ │ ├── DecAssignArr.hpp │ │ │ ├── Declare.hpp │ │ │ ├── Delete.hpp │ │ │ ├── Destructure.hpp │ │ │ ├── Enum.hpp │ │ │ ├── For.hpp │ │ │ ├── ForEach.hpp │ │ │ ├── Function.hpp │ │ │ ├── If.hpp │ │ │ ├── Import.hpp │ │ │ ├── Inc.hpp │ │ │ ├── Return.hpp │ │ │ ├── Sequence.hpp │ │ │ ├── Struct.hpp │ │ │ ├── Transform.hpp │ │ │ └── While.hpp │ ├── Lower.hpp │ └── Parser.hpp ├── PreProcessor.hpp ├── Scanner.hpp └── Utils.hpp ├── install.sh ├── libraries └── std │ ├── asm.s │ ├── docs │ ├── Collections.MD │ ├── String.MD │ ├── System.MD │ └── strings.MD │ ├── head │ ├── asm.gs │ ├── request.gs │ ├── server.gs │ ├── std.gs │ └── strings.gs │ └── src │ ├── ATest.af │ ├── CLArgs.af │ ├── Collections.af │ ├── Collections │ ├── Enumerator.af │ ├── Iterator.af │ └── Scroller.af │ ├── DateTime.af │ ├── HTTP.af │ ├── HTTP │ ├── Endpoint.af │ ├── Endpoints.af │ ├── Middleware.af │ └── Server.af │ ├── JSON.af │ ├── JSON │ ├── Parse.af │ └── Property.af │ ├── Memory.af │ ├── String.af │ ├── System.af │ ├── Utils │ ├── Defer.af │ ├── Error.af │ ├── Error │ │ └── Render.af │ ├── Functions.af │ ├── Map.af │ ├── Object.af │ ├── Observable.af │ ├── Option.af │ ├── Properties.af │ └── Result.af │ ├── Web │ ├── Content.af │ └── Content │ │ └── Bind.af │ ├── concurrency.af │ ├── files.af │ ├── io.af │ ├── math.af │ ├── request.c │ ├── std-cmp.af │ ├── std.af │ └── strings.af ├── makefile ├── rebuild-libs.sh ├── src ├── ASM.cpp ├── CodeGenerator │ ├── CodeGenerator.cpp │ ├── MockCodeGenerator.cpp │ ├── ScopeManage.cpp │ └── Utils.cpp ├── CompilerUtils.cpp ├── Configs.cpp ├── Exceptions.cpp ├── Parser │ ├── AST.cpp │ ├── AST │ │ └── Statements │ │ │ ├── Assign.cpp │ │ │ ├── Break.cpp │ │ │ ├── Call.cpp │ │ │ ├── Class.cpp │ │ │ ├── Continue.cpp │ │ │ ├── Dec.cpp │ │ │ ├── DecArr.cpp │ │ │ ├── DecAssign.cpp │ │ │ ├── DecAssingArr.cpp │ │ │ ├── Declare.cpp │ │ │ ├── Delete.cpp │ │ │ ├── Destructure.cpp │ │ │ ├── Enum.cpp │ │ │ ├── For.cpp │ │ │ ├── ForEach.cpp │ │ │ ├── Function.cpp │ │ │ ├── If.cpp │ │ │ ├── Import.cpp │ │ │ ├── Inc.cpp │ │ │ ├── Return.cpp │ │ │ ├── Sequence.cpp │ │ │ ├── Struct.cpp │ │ │ ├── Transform.cpp │ │ │ └── While.cpp │ ├── Lower.cpp │ └── Parser.cpp ├── PreProcessor.cpp ├── Scanner.cpp ├── Utils.cpp ├── main.af ├── main.cpp └── test │ └── test.af └── test ├── catch.hpp ├── test.cpp ├── test_ASM.cpp ├── test_CodeGenerator.cpp ├── test_CompilerUtils.cpp ├── test_Configs.cpp ├── test_Exceptions.cpp ├── test_HashMap.cpp ├── test_LinkedList.cpp ├── test_More.cpp ├── test_PreProcessor.cpp ├── test_SLinkedList.cpp ├── test_Scanner.cpp ├── test_ScopeManager.cpp └── test_Utils.cpp /.github/workflows/cmake.yml: -------------------------------------------------------------------------------- 1 | name: CMake 2 | 3 | on: 4 | push: 5 | branches: [ "main" ] 6 | pull_request: 7 | branches: [ "main" ] 8 | 9 | env: 10 | BUILD_TYPE: Release 11 | 12 | jobs: 13 | build: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v3 17 | - name: Install Boost 18 | run: sudo apt-get install libboost-all-dev 19 | - name: create Build Dir 20 | run: mkdir build 21 | - name: Configure CMake 22 | working-directory: ${{github.workspace}}/build 23 | run: cmake .. 24 | - name: Build 25 | run: cmake --build build && bash ./rebuild-libs.sh && ./bin/aflat build 26 | - name: Test 27 | working-directory: ${{github.workspace}}/bin 28 | run: ./test 29 | 30 | check-format: 31 | runs-on: ubuntu-latest 32 | steps: 33 | - uses: actions/checkout@v3 34 | - name: Install clang-format with npm 35 | run: npm install -g clang-format 36 | - name: Check code formatting 37 | working-directory: ${{github.workspace}} 38 | run: | 39 | find . -path ./Lib -prune -o -path ./test/catch.hpp -prune -o -regex '.*\.\(cpp\|hpp\)' -exec clang-format -style=file -i {} \+ -exec git add {} \+ 40 | git diff --cached --exit-code 41 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.vscode/** 2 | /KeyPair.pem 3 | /aflat-doc/** 4 | /bin/** 5 | /libraries/std/*.s 6 | !/libraries/std/asm.s 7 | /build/** 8 | # Coverage 9 | /coverage 10 | /coverage.info 11 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 2 | add_subdirectory(Lib/Catch2) 3 | 4 | set (CMAKE_CXX_STANDARD 17) 5 | set (GCC_COMPILER_FLAGS -O3 -march=native -flto -fpermissive) 6 | set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ../bin) 7 | project(aflat VERSION 1.1.0) 8 | 9 | file(GLOB_RECURSE aflat_SRC 10 | src/*.cpp 11 | ) 12 | 13 | # add boost 14 | find_package(Boost 1.71.0 REQUIRED) 15 | include_directories(${Boost_INCLUDE_DIRS}) 16 | 17 | add_compile_options(${GCC_COMPILER_FLAGS}) 18 | add_executable(aflat ${aflat_SRC}) 19 | target_link_options(aflat PRIVATE -flto) 20 | 21 | target_include_directories(aflat PRIVATE include/) 22 | 23 | # Testing --> 24 | file(GLOB_RECURSE testing_Modules 25 | test/*.cpp 26 | src/CodeGenerator/*.cpp 27 | src/*.cpp 28 | ) 29 | 30 | list(REMOVE_ITEM testing_Modules ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp) 31 | 32 | message (STATUS ${testing_Modules}) 33 | add_executable(test ${testing_Modules}) 34 | target_include_directories(test PRIVATE include/) 35 | target_link_libraries(test PRIVATE Catch2::Catch2WithMain) 36 | target_link_options(test PRIVATE -flto) 37 | -------------------------------------------------------------------------------- /Lib/Catch2/.bazelrc: -------------------------------------------------------------------------------- 1 | build:gcc9 --cxxopt=-std=c++2a 2 | build:clang13 --cxxopt=-std=c++17 3 | build:vs2019 --cxxopt=/std:c++17 4 | build:vs2022 --cxxopt=/std:c++17 -------------------------------------------------------------------------------- /Lib/Catch2/.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | AccessModifierOffset: '-4' 3 | AlignEscapedNewlines: Left 4 | AllowAllConstructorInitializersOnNextLine: 'true' 5 | BinPackArguments: 'false' 6 | BinPackParameters: 'false' 7 | BreakConstructorInitializers: AfterColon 8 | ConstructorInitializerAllOnOneLineOrOnePerLine: 'true' 9 | DerivePointerAlignment: 'false' 10 | FixNamespaceComments: 'true' 11 | IncludeBlocks: Regroup 12 | IndentCaseLabels: 'false' 13 | IndentPPDirectives: AfterHash 14 | IndentWidth: '4' 15 | Language: Cpp 16 | NamespaceIndentation: All 17 | PointerAlignment: Left 18 | SpaceBeforeCtorInitializerColon: 'false' 19 | SpaceInEmptyParentheses: 'false' 20 | SpacesInParentheses: 'true' 21 | Standard: Cpp11 22 | TabWidth: '4' 23 | UseTab: Never 24 | 25 | ... 26 | -------------------------------------------------------------------------------- /Lib/Catch2/.conan/test_package/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2.0) 2 | project(test_package CXX) 3 | 4 | include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") 5 | conan_basic_setup() 6 | 7 | find_package(Catch2 REQUIRED CONFIG) 8 | 9 | add_executable(${PROJECT_NAME} test_package.cpp) 10 | 11 | target_link_libraries(${PROJECT_NAME} Catch2::Catch2WithMain) 12 | set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 14) 13 | -------------------------------------------------------------------------------- /Lib/Catch2/.conan/test_package/conanfile.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | from conans import ConanFile, CMake 4 | import os 5 | 6 | 7 | class TestPackageConan(ConanFile): 8 | settings = "os", "compiler", "build_type", "arch" 9 | generators = "cmake_find_package_multi", "cmake" 10 | 11 | def build(self): 12 | cmake = CMake(self) 13 | cmake.configure() 14 | cmake.build() 15 | 16 | def test(self): 17 | assert os.path.isfile(os.path.join( 18 | self.deps_cpp_info["catch2"].rootpath, "licenses", "LICENSE.txt")) 19 | bin_path = os.path.join("bin", "test_package") 20 | self.run("%s -s" % bin_path, run_environment=True) 21 | -------------------------------------------------------------------------------- /Lib/Catch2/.conan/test_package/test_package.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int Factorial( int number ) { 4 | return number <= 1 ? 1 : Factorial( number - 1 ) * number; 5 | } 6 | 7 | TEST_CASE( "Factorial Tests", "[single-file]" ) { 8 | REQUIRE( Factorial( 0 ) == 1 ); 9 | REQUIRE( Factorial( 1 ) == 1 ); 10 | REQUIRE( Factorial( 2 ) == 2 ); 11 | REQUIRE( Factorial( 3 ) == 6 ); 12 | REQUIRE( Factorial( 10 ) == 3628800 ); 13 | } -------------------------------------------------------------------------------- /Lib/Catch2/.gitattributes: -------------------------------------------------------------------------------- 1 | # This sets the default behaviour, overriding core.autocrlf 2 | * text=auto 3 | 4 | # All source files should have unix line-endings in the repository, 5 | # but convert to native line-endings on checkout 6 | *.cpp text 7 | *.h text 8 | *.hpp text 9 | 10 | # Windows specific files should retain windows line-endings 11 | *.sln text eol=crlf 12 | 13 | # Keep executable scripts with LFs so they can be run after being 14 | # checked out on Windows 15 | *.py text eol=lf 16 | 17 | 18 | # Keep the single include header with LFs to make sure it is uploaded, 19 | # hashed etc with LF 20 | single_include/**/*.hpp eol=lf 21 | # Also keep the LICENCE file with LFs for the same reason 22 | LICENCE.txt eol=lf 23 | -------------------------------------------------------------------------------- /Lib/Catch2/.gitignore: -------------------------------------------------------------------------------- 1 | *.build 2 | *.pbxuser 3 | *.mode1v3 4 | *.ncb 5 | *.suo 6 | Debug 7 | Release 8 | *.user 9 | *.xcuserstate 10 | .DS_Store 11 | xcuserdata 12 | CatchSelfTest.xcscheme 13 | Breakpoints.xcbkptlist 14 | UpgradeLog.XML 15 | Resources/DWARF 16 | projects/Generated 17 | *.pyc 18 | DerivedData 19 | *.xccheckout 20 | Build 21 | .idea 22 | .vs 23 | .vscode 24 | cmake-build-* 25 | benchmark-dir 26 | .conan/test_package/build 27 | bazel-* 28 | build-fuzzers 29 | debug-build 30 | .vscode 31 | msvc-sln* 32 | # Currently we use Doxygen for dep graphs and the full docs are only slowly 33 | # being filled in, so we definitely do not want git to deal with the docs. 34 | docs/doxygen 35 | *.cache 36 | compile_commands.json 37 | -------------------------------------------------------------------------------- /Lib/Catch2/CMake/Catch2Config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | 4 | # Avoid repeatedly including the targets 5 | if(NOT TARGET Catch2::Catch2) 6 | # Provide path for scripts 7 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") 8 | 9 | include(${CMAKE_CURRENT_LIST_DIR}/Catch2Targets.cmake) 10 | endif() 11 | -------------------------------------------------------------------------------- /Lib/Catch2/CMake/catch2-with-main.pc.in: -------------------------------------------------------------------------------- 1 | includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ 2 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 3 | pkg_version=@Catch2_VERSION@ 4 | 5 | Name: Catch2-With-Main 6 | Description: A modern, C++-native test framework for C++14 and above (links in default main) 7 | Version: ${pkg_version} 8 | Requires: catch2 = ${pkg_version} 9 | Cflags: -I${includedir} 10 | Libs: -L${libdir} -lCatch2Main 11 | -------------------------------------------------------------------------------- /Lib/Catch2/CMake/catch2.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=${prefix} 3 | includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ 4 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 5 | 6 | Name: Catch2 7 | Description: A modern, C++-native, test framework for C++14 and above 8 | URL: https://github.com/catchorg/Catch2 9 | Version: @Catch2_VERSION@ 10 | Cflags: -I${includedir} 11 | Libs: -L${libdir} -lCatch2 12 | -------------------------------------------------------------------------------- /Lib/Catch2/CMake/llvm-cov-wrapper: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This file is part of CMake-codecov. 4 | # 5 | # Copyright (c) 6 | # 2015-2017 RWTH Aachen University, Federal Republic of Germany 7 | # 8 | # See the LICENSE file in the package base directory for details 9 | # 10 | # Written by Alexander Haase, alexander.haase@rwth-aachen.de 11 | # 12 | 13 | if [ -z "$LLVM_COV_BIN" ] 14 | then 15 | echo "LLVM_COV_BIN not set!" >& 2 16 | exit 1 17 | fi 18 | 19 | 20 | # Get LLVM version to find out. 21 | LLVM_VERSION=$($LLVM_COV_BIN -version | grep -i "LLVM version" \ 22 | | sed "s/^\([A-Za-z ]*\)\([0-9]\).\([0-9]\).*$/\2.\3/g") 23 | 24 | if [ "$1" = "-v" ] 25 | then 26 | echo "llvm-cov-wrapper $LLVM_VERSION" 27 | exit 0 28 | fi 29 | 30 | 31 | if [ -n "$LLVM_VERSION" ] 32 | then 33 | MAJOR=$(echo $LLVM_VERSION | cut -d'.' -f1) 34 | MINOR=$(echo $LLVM_VERSION | cut -d'.' -f2) 35 | 36 | if [ $MAJOR -eq 3 ] && [ $MINOR -le 4 ] 37 | then 38 | if [ -f "$1" ] 39 | then 40 | filename=$(basename "$1") 41 | extension="${filename##*.}" 42 | 43 | case "$extension" in 44 | "gcno") exec $LLVM_COV_BIN --gcno="$1" ;; 45 | "gcda") exec $LLVM_COV_BIN --gcda="$1" ;; 46 | esac 47 | fi 48 | fi 49 | 50 | if [ $MAJOR -eq 3 ] && [ $MINOR -le 5 ] 51 | then 52 | exec $LLVM_COV_BIN $@ 53 | fi 54 | fi 55 | 56 | exec $LLVM_COV_BIN gcov $@ 57 | -------------------------------------------------------------------------------- /Lib/Catch2/CMakePresets.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "configurePresets": [ 4 | { 5 | "name": "basic-tests", 6 | "displayName": "Basic development build", 7 | "description": "Enables development build with basic tests that are cheap to build and run", 8 | "cacheVariables": { 9 | "CATCH_DEVELOPMENT_BUILD": "ON" 10 | } 11 | }, 12 | { 13 | "name": "all-tests", 14 | "inherits": "basic-tests", 15 | "displayName": "Full development build", 16 | "description": "Enables development build with examples and ALL tests", 17 | "cacheVariables": { 18 | "CATCH_BUILD_EXAMPLES": "ON", 19 | "CATCH_BUILD_EXTRA_TESTS": "ON", 20 | "CATCH_BUILD_SURROGATES": "ON", 21 | "CATCH_ENABLE_CONFIGURE_TESTS": "ON" 22 | } 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /Lib/Catch2/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Boost Software License - Version 1.0 - August 17th, 2003 2 | 3 | Permission is hereby granted, free of charge, to any person or organization 4 | obtaining a copy of the software and accompanying documentation covered by 5 | this license (the "Software") to use, reproduce, display, distribute, 6 | execute, and transmit the Software, and to prepare derivative works of the 7 | Software, and to permit third-parties to whom the Software is furnished to 8 | do so, all subject to the following: 9 | 10 | The copyright notices in the Software and this entire statement, including 11 | the above license grant, this restriction and the following disclaimer, 12 | must be included in all copies of the Software, in whole or in part, and 13 | all derivative works of the Software, unless such copies or derivative 14 | works are solely in the form of machine-executable object code generated by 15 | a source language processor. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 20 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 21 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 22 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /Lib/Catch2/SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | * Versions 1.x (branch Catch1.x) are no longer supported. 6 | * Versions 2.x (branch v2.x) are currently supported. 7 | * `devel` branch serves for stable-ish development and is supported, 8 | but branches `devel-*` are considered short lived and are not supported separately. 9 | 10 | 11 | ## Reporting a Vulnerability 12 | 13 | Due to its nature as a _unit_ test framework, Catch2 shouldn't interact 14 | with untrusted inputs and there shouldn't be many security vulnerabilities 15 | in it. 16 | 17 | However, if you find one you send email to martin horenovsky 18 | gmail com. If you want to encrypt the email, my pgp key is 19 | `E29C 46F3 B8A7 5028 6079 3B7D ECC9 C20E 314B 2360`. 20 | -------------------------------------------------------------------------------- /Lib/Catch2/WORKSPACE: -------------------------------------------------------------------------------- 1 | load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 2 | 3 | http_archive( 4 | name = "bazel_skylib", 5 | strip_prefix = "bazel-skylib-2a87d4a62af886fb320883aba102255aba87275e", 6 | urls = [ 7 | "https://github.com/bazelbuild/bazel-skylib/archive/2a87d4a62af886fb320883aba102255aba87275e.tar.gz", 8 | ], 9 | sha256 = "d847b08d6702d2779e9eb399b54ff8920fa7521dc45e3e53572d1d8907767de7", 10 | ) 11 | 12 | load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") 13 | 14 | bazel_skylib_workspace() -------------------------------------------------------------------------------- /Lib/Catch2/codecov.yml: -------------------------------------------------------------------------------- 1 | coverage: 2 | precision: 2 3 | round: nearest 4 | range: "60...90" 5 | status: 6 | project: 7 | default: 8 | threshold: 2% 9 | patch: 10 | default: 11 | target: 80% 12 | ignore: 13 | - "**/external/clara.hpp" 14 | - "tests" 15 | 16 | 17 | codecov: 18 | branch: devel 19 | max_report_age: off 20 | 21 | comment: 22 | layout: "diff" 23 | -------------------------------------------------------------------------------- /Lib/Catch2/data/artwork/catch2-c-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeForestt/aflat/c86f1660e241f3426b1bf39bbccd8fcce9e8f4e9/Lib/Catch2/data/artwork/catch2-c-logo.png -------------------------------------------------------------------------------- /Lib/Catch2/data/artwork/catch2-hand-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeForestt/aflat/c86f1660e241f3426b1bf39bbccd8fcce9e8f4e9/Lib/Catch2/data/artwork/catch2-hand-logo.png -------------------------------------------------------------------------------- /Lib/Catch2/data/artwork/catch2-logo-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeForestt/aflat/c86f1660e241f3426b1bf39bbccd8fcce9e8f4e9/Lib/Catch2/data/artwork/catch2-logo-small.png -------------------------------------------------------------------------------- /Lib/Catch2/docs/commercial-users.md: -------------------------------------------------------------------------------- 1 | 2 | # Commercial users of Catch2 3 | 4 | Catch2 is also widely used in proprietary code bases. This page contains 5 | some of them that are willing to share this information. 6 | 7 | If you want to add your organisation, please check that there is no issue 8 | with you sharing this fact. 9 | 10 | - Bloomberg 11 | - [Bloomlife](https://bloomlife.com) 12 | - [Inscopix Inc.](https://www.inscopix.com/) 13 | - Locksley.CZ 14 | - [Makimo](https://makimo.pl/) 15 | - NASA 16 | - [Nexus Software Systems](https://nexwebsites.com) 17 | - [UX3D](https://ux3d.io) 18 | - [King](https://king.com) 19 | 20 | 21 | --- 22 | 23 | [Home](Readme.md#top) 24 | -------------------------------------------------------------------------------- /Lib/Catch2/docs/deprecations.md: -------------------------------------------------------------------------------- 1 | 2 | # Deprecations and incoming changes 3 | 4 | This page documents current deprecations and upcoming planned changes 5 | inside Catch2. The difference between these is that a deprecated feature 6 | will be removed, while a planned change to a feature means that the 7 | feature will behave differently, but will still be present. Obviously, 8 | either of these is a breaking change, and thus will not happen until 9 | at least the next major release. 10 | 11 | 12 | ### `ParseAndAddCatchTests.cmake` 13 | 14 | The CMake/CTest integration using `ParseAndAddCatchTests.cmake` is deprecated, 15 | as it can be replaced by `Catch.cmake` that provides the function 16 | `catch_discover_tests` to get tests directly from a CMake target via the 17 | command line interface instead of parsing C++ code with regular expressions. 18 | 19 | 20 | ### `CATCH_CONFIG_BAZEL_SUPPORT` 21 | 22 | Catch2 supports writing the Bazel JUnit XML output file when it is aware 23 | that is within a bazel testing environment. Originally there was no way 24 | to accurately probe the environment for this information so the flag 25 | `CATCH_CONFIG_BAZEL_SUPPORT` was added. This now deprecated. Bazel has now had a change 26 | where it will export `BAZEL_TEST=1` for purposes like the above. Catch2 27 | will now instead inspect the environment instead of relying on build configuration. 28 | 29 | --- 30 | 31 | [Home](Readme.md#top) 32 | -------------------------------------------------------------------------------- /Lib/Catch2/examples/020-TestCase-1.cpp: -------------------------------------------------------------------------------- 1 | // 020-TestCase-1.cpp 2 | 3 | #include 4 | 5 | TEST_CASE( "1: All test cases reside in other .cpp files (empty)", 6 | "[multi-file:1]" ) {} 7 | 8 | // ^^^ 9 | // Normally no TEST_CASEs in this file. 10 | // Here just to show there are two source files via option --list-tests. 11 | 12 | // Compile & run: 13 | // - g++ -std=c++14 -Wall -I$(CATCH_SINGLE_INCLUDE) -c 020-TestCase-1.cpp 14 | // - g++ -std=c++14 -Wall -I$(CATCH_SINGLE_INCLUDE) -o 020-TestCase TestCase-1.o 15 | // 020-TestCase-2.cpp && 020-TestCase --success 16 | // 17 | // - cl -EHsc -I%CATCH_SINGLE_INCLUDE% -c 020-TestCase-1.cpp 18 | // - cl -EHsc -I%CATCH_SINGLE_INCLUDE% -Fe020-TestCase.exe 020-TestCase-1.obj 19 | // 020-TestCase-2.cpp && 020-TestCase --success 20 | 21 | // Expected test case listing: 22 | // 23 | // prompt> 020-TestCase --list-tests * 24 | // Matching test cases: 25 | // 1: All test cases reside in other .cpp files (empty) 26 | // [multi-file:1] 27 | // 2: Factorial of 0 is computed (fail) 28 | // [multi-file:2] 29 | // 2: Factorials of 1 and higher are computed (pass) 30 | // [multi-file:2] 31 | // 3 matching test cases 32 | -------------------------------------------------------------------------------- /Lib/Catch2/examples/020-TestCase-2.cpp: -------------------------------------------------------------------------------- 1 | // 020-TestCase-2.cpp 2 | 3 | // main() provided by Catch in file 020-TestCase-1.cpp. 4 | 5 | #include 6 | 7 | static int Factorial( int number ) { 8 | return number <= 1 ? number : Factorial( number - 1 ) * number; // fail 9 | // return number <= 1 ? 1 : Factorial( number - 1 ) * number; // pass 10 | } 11 | 12 | TEST_CASE( "2: Factorial of 0 is 1 (fail)", "[multi-file:2]" ) { 13 | REQUIRE( Factorial( 0 ) == 1 ); 14 | } 15 | 16 | TEST_CASE( "2: Factorials of 1 and higher are computed (pass)", 17 | "[multi-file:2]" ) { 18 | REQUIRE( Factorial( 1 ) == 1 ); 19 | REQUIRE( Factorial( 2 ) == 2 ); 20 | REQUIRE( Factorial( 3 ) == 6 ); 21 | REQUIRE( Factorial( 10 ) == 3628800 ); 22 | } 23 | 24 | // Compile: see 020-TestCase-1.cpp 25 | 26 | // Expected compact output (all assertions): 27 | // 28 | // prompt> 020-TestCase --reporter compact --success 29 | // 020-TestCase-2.cpp:13: failed: Factorial(0) == 1 for: 0 == 1 30 | // 020-TestCase-2.cpp:17: passed: Factorial(1) == 1 for: 1 == 1 31 | // 020-TestCase-2.cpp:18: passed: Factorial(2) == 2 for: 2 == 2 32 | // 020-TestCase-2.cpp:19: passed: Factorial(3) == 6 for: 6 == 6 33 | // 020-TestCase-2.cpp:20: passed: Factorial(10) == 3628800 for: 3628800 34 | // (0x375f00) == 3628800 (0x375f00) Failed 1 test case, failed 1 assertion. 35 | -------------------------------------------------------------------------------- /Lib/Catch2/extras/gdbinit: -------------------------------------------------------------------------------- 1 | # 2 | # This file provides a way to skip stepping into Catch code when debugging with gdb. 3 | # 4 | # With the gdb "skip" command you can tell gdb to skip files or functions during debugging. 5 | # see https://xaizek.github.io/2016-05-26/skipping-standard-library-in-gdb/ for an example 6 | # 7 | # Basically the following line tells gdb to skip all functions containing the 8 | # regexp "Catch", which matches the complete Catch namespace. 9 | # If you want to skip just some parts of the Catch code you can modify the 10 | # regexp accordingly. 11 | # 12 | # If you want to permanently skip stepping into Catch code copy the following 13 | # line into your ~/.gdbinit file 14 | # 15 | 16 | skip -rfu Catch 17 | -------------------------------------------------------------------------------- /Lib/Catch2/extras/lldbinit: -------------------------------------------------------------------------------- 1 | # 2 | # This file provides a way to skip stepping into Catch code when debugging with lldb. 3 | # 4 | # With the setting "target.process.thread.step-avoid-regexp" you can tell lldb 5 | # to skip functions matching the regexp 6 | # 7 | # Basically the following line tells lldb to skip all functions containing the 8 | # regexp "Catch", which matches the complete Catch namespace. 9 | # If you want to skip just some parts of the Catch code you can modify the 10 | # regexp accordingly. 11 | # 12 | # If you want to permanently skip stepping into Catch code copy the following 13 | # line into your ~/.lldbinit file 14 | # 15 | 16 | settings set target.process.thread.step-avoid-regexp Catch -------------------------------------------------------------------------------- /Lib/Catch2/fuzzing/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # License: Boost 1.0 2 | # By Paul Dreik 2020 3 | 4 | # add a library that brings in the main() function from libfuzzer 5 | # and has all the dependencies, so the individual fuzzers can be 6 | # added one line each. 7 | add_library(fuzzhelper NullOStream.h NullOStream.cpp) 8 | target_link_libraries(fuzzhelper PUBLIC Catch2::Catch2) 9 | 10 | # use C++17 so we can get string_view 11 | target_compile_features(fuzzhelper PUBLIC cxx_std_17) 12 | 13 | # This should be possible to set from the outside to be oss-fuzz compatible, 14 | # fix later. For now, target libFuzzer only. 15 | target_link_options(fuzzhelper PUBLIC "-fsanitize=fuzzer") 16 | 17 | foreach(fuzzer TestSpecParser XmlWriter textflow) 18 | add_executable(fuzz_${fuzzer} fuzz_${fuzzer}.cpp) 19 | target_link_libraries(fuzz_${fuzzer} PRIVATE fuzzhelper) 20 | endforeach() 21 | -------------------------------------------------------------------------------- /Lib/Catch2/fuzzing/NullOStream.cpp: -------------------------------------------------------------------------------- 1 | #include "NullOStream.h" 2 | 3 | void NullOStream::avoidOutOfLineVirtualCompilerWarning() 4 | { 5 | } 6 | 7 | int NullStreambuf::overflow(int c){ 8 | setp(dummyBuffer, dummyBuffer + sizeof(dummyBuffer)); 9 | return (c == traits_type::eof()) ? '\0' : c; 10 | } 11 | -------------------------------------------------------------------------------- /Lib/Catch2/fuzzing/NullOStream.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | // from https://stackoverflow.com/a/8244052 7 | class NullStreambuf : public std::streambuf { 8 | char dummyBuffer[64]; 9 | 10 | protected: 11 | virtual int overflow(int c) override final; 12 | }; 13 | 14 | class NullOStream final : private NullStreambuf, public std::ostream { 15 | public: 16 | NullOStream() : std::ostream(this) {} 17 | NullStreambuf *rdbuf() { return this; } 18 | virtual void avoidOutOfLineVirtualCompilerWarning(); 19 | }; 20 | 21 | -------------------------------------------------------------------------------- /Lib/Catch2/fuzzing/build_fuzzers.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Builds the fuzzers 4 | # 5 | # By Paul Dreik 20200923 6 | set -exu 7 | 8 | CATCHROOT=$(readlink -f $(dirname $0)/..) 9 | 10 | 11 | BUILDDIR=$CATCHROOT/build-fuzzers 12 | mkdir -p $BUILDDIR 13 | cd $BUILDDIR 14 | 15 | if which /usr/lib/ccache/clang++ >/dev/null 2>&1 ; then 16 | CXX=/usr/lib/ccache/clang++ 17 | else 18 | CXX=clang++ 19 | fi 20 | 21 | cmake $CATCHROOT \ 22 | -DCMAKE_CXX_COMPILER=$CXX \ 23 | -DCMAKE_CXX_FLAGS="-fsanitize=fuzzer-no-link,address,undefined -O3 -g" \ 24 | -DCATCH_DEVELOPMENT_BUILD=On \ 25 | -DCATCH_BUILD_EXAMPLES=Off \ 26 | -DCATCH_BUILD_EXTRA_TESTS=Off \ 27 | -DCATCH_BUILD_TESTING=Off \ 28 | -DBUILD_TESTING=Off \ 29 | -DCATCH_ENABLE_WERROR=Off \ 30 | -DCATCH_BUILD_FUZZERS=On 31 | 32 | cmake --build . -j $(nproc) 33 | 34 | -------------------------------------------------------------------------------- /Lib/Catch2/fuzzing/fuzz_TestSpecParser.cpp: -------------------------------------------------------------------------------- 1 | //License: Boost 1.0 2 | //By Paul Dreik 2020 3 | 4 | #include 5 | #include 6 | 7 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { 8 | 9 | Catch::TagAliasRegistry tar; 10 | Catch::TestSpecParser tsp(tar); 11 | 12 | std::string buf(Data,Data+Size); 13 | tsp.parse(buf); 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /Lib/Catch2/fuzzing/fuzz_XmlWriter.cpp: -------------------------------------------------------------------------------- 1 | //License: Boost 1.0 2 | //By Paul Dreik 2020 3 | 4 | #include 5 | 6 | #include "NullOStream.h" 7 | 8 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { 9 | 10 | std::string buf(Data,Data+Size); 11 | NullOStream nul; 12 | Catch::XmlEncode encode(buf); 13 | encode.encodeTo(nul); 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /Lib/Catch2/fuzzing/fuzz_textflow.cpp: -------------------------------------------------------------------------------- 1 | //License: Boost 1.0 2 | //By Paul Dreik 2020 3 | 4 | #include 5 | 6 | #include "NullOStream.h" 7 | 8 | #include 9 | #include 10 | 11 | 12 | template 13 | void split(const char *Data, size_t Size, Callback callback) { 14 | 15 | using namespace std::literals; 16 | constexpr auto sep="\n~~~\n"sv; 17 | 18 | std::string_view remainder(Data,Size); 19 | for (;;) { 20 | auto pos=remainder.find(sep); 21 | if(pos==std::string_view::npos) { 22 | //not found. use the remainder and exit 23 | callback(remainder); 24 | return; 25 | } else { 26 | //found. invoke callback on the first part, then proceed with the rest. 27 | callback(remainder.substr(0,pos)); 28 | remainder=remainder.substr(pos+sep.size()); 29 | } 30 | } 31 | } 32 | 33 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { 34 | 35 | Catch::TextFlow::Columns columns; 36 | 37 | // break the input on separator 38 | split((const char*)Data,Size,[&](std::string_view word) { 39 | columns+=Catch::TextFlow::Column(std::string(word)); 40 | }); 41 | 42 | NullOStream nul; 43 | nul << columns; 44 | 45 | return 0; 46 | } 47 | 48 | -------------------------------------------------------------------------------- /Lib/Catch2/mdsnippets.json: -------------------------------------------------------------------------------- 1 | { 2 | "ReadOnly": false, 3 | "TocLevel": 5, 4 | "Exclude": [ 5 | "cmake-build" 6 | ], 7 | "WriteHeader": false, 8 | "Convention": "InPlaceOverwrite" 9 | } 10 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/benchmark/catch_chronometer.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | namespace Catch { 12 | namespace Benchmark { 13 | namespace Detail { 14 | ChronometerConcept::~ChronometerConcept() = default; 15 | } // namespace Detail 16 | } // namespace Benchmark 17 | } // namespace Catch 18 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/benchmark/catch_clock.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | // Adapted from donated nonius code. 9 | 10 | #ifndef CATCH_CLOCK_HPP_INCLUDED 11 | #define CATCH_CLOCK_HPP_INCLUDED 12 | 13 | #include 14 | #include 15 | 16 | namespace Catch { 17 | namespace Benchmark { 18 | template 19 | using ClockDuration = typename Clock::duration; 20 | template 21 | using FloatDuration = std::chrono::duration; 22 | 23 | template 24 | using TimePoint = typename Clock::time_point; 25 | 26 | using default_clock = std::chrono::steady_clock; 27 | 28 | template 29 | struct now { 30 | TimePoint operator()() const { 31 | return Clock::now(); 32 | } 33 | }; 34 | 35 | using fp_seconds = std::chrono::duration>; 36 | } // namespace Benchmark 37 | } // namespace Catch 38 | 39 | #endif // CATCH_CLOCK_HPP_INCLUDED 40 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/benchmark/catch_environment.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | // Adapted from donated nonius code. 9 | 10 | #ifndef CATCH_ENVIRONMENT_HPP_INCLUDED 11 | #define CATCH_ENVIRONMENT_HPP_INCLUDED 12 | 13 | #include 14 | #include 15 | 16 | namespace Catch { 17 | namespace Benchmark { 18 | template 19 | struct EnvironmentEstimate { 20 | Duration mean; 21 | OutlierClassification outliers; 22 | 23 | template 24 | operator EnvironmentEstimate() const { 25 | return { mean, outliers }; 26 | } 27 | }; 28 | template 29 | struct Environment { 30 | using clock_type = Clock; 31 | EnvironmentEstimate> clock_resolution; 32 | EnvironmentEstimate> clock_cost; 33 | }; 34 | } // namespace Benchmark 35 | } // namespace Catch 36 | 37 | #endif // CATCH_ENVIRONMENT_HPP_INCLUDED 38 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/benchmark/catch_estimate.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | // Adapted from donated nonius code. 9 | 10 | #ifndef CATCH_ESTIMATE_HPP_INCLUDED 11 | #define CATCH_ESTIMATE_HPP_INCLUDED 12 | 13 | namespace Catch { 14 | namespace Benchmark { 15 | template 16 | struct Estimate { 17 | Duration point; 18 | Duration lower_bound; 19 | Duration upper_bound; 20 | double confidence_interval; 21 | 22 | template 23 | operator Estimate() const { 24 | return { point, lower_bound, upper_bound, confidence_interval }; 25 | } 26 | }; 27 | } // namespace Benchmark 28 | } // namespace Catch 29 | 30 | #endif // CATCH_ESTIMATE_HPP_INCLUDED 31 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/benchmark/catch_outlier_classification.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | // Adapted from donated nonius code. 9 | 10 | #ifndef CATCH_OUTLIER_CLASSIFICATION_HPP_INCLUDED 11 | #define CATCH_OUTLIER_CLASSIFICATION_HPP_INCLUDED 12 | 13 | namespace Catch { 14 | namespace Benchmark { 15 | struct OutlierClassification { 16 | int samples_seen = 0; 17 | int low_severe = 0; // more than 3 times IQR below Q1 18 | int low_mild = 0; // 1.5 to 3 times IQR below Q1 19 | int high_mild = 0; // 1.5 to 3 times IQR above Q3 20 | int high_severe = 0; // more than 3 times IQR above Q3 21 | 22 | int total() const { 23 | return low_severe + low_mild + high_mild + high_severe; 24 | } 25 | }; 26 | } // namespace Benchmark 27 | } // namespace Catch 28 | 29 | #endif // CATCH_OUTLIERS_CLASSIFICATION_HPP_INCLUDED 30 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/benchmark/detail/catch_benchmark_function.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | namespace Catch { 12 | namespace Benchmark { 13 | namespace Detail { 14 | BenchmarkFunction::callable::~callable() = default; 15 | } // namespace Detail 16 | } // namespace Benchmark 17 | } // namespace Catch 18 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/benchmark/detail/catch_measure.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | // Adapted from donated nonius code. 9 | 10 | #ifndef CATCH_MEASURE_HPP_INCLUDED 11 | #define CATCH_MEASURE_HPP_INCLUDED 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | namespace Catch { 19 | namespace Benchmark { 20 | namespace Detail { 21 | template 22 | TimingOf measure(Fun&& fun, Args&&... args) { 23 | auto start = Clock::now(); 24 | auto&& r = Detail::complete_invoke(fun, CATCH_FORWARD(args)...); 25 | auto end = Clock::now(); 26 | auto delta = end - start; 27 | return { delta, CATCH_FORWARD(r), 1 }; 28 | } 29 | } // namespace Detail 30 | } // namespace Benchmark 31 | } // namespace Catch 32 | 33 | #endif // CATCH_MEASURE_HPP_INCLUDED 34 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/benchmark/detail/catch_repeat.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | // Adapted from donated nonius code. 9 | 10 | #ifndef CATCH_REPEAT_HPP_INCLUDED 11 | #define CATCH_REPEAT_HPP_INCLUDED 12 | 13 | #include 14 | #include 15 | 16 | namespace Catch { 17 | namespace Benchmark { 18 | namespace Detail { 19 | template 20 | struct repeater { 21 | void operator()(int k) const { 22 | for (int i = 0; i < k; ++i) { 23 | fun(); 24 | } 25 | } 26 | Fun fun; 27 | }; 28 | template 29 | repeater> repeat(Fun&& fun) { 30 | return { CATCH_FORWARD(fun) }; 31 | } 32 | } // namespace Detail 33 | } // namespace Benchmark 34 | } // namespace Catch 35 | 36 | #endif // CATCH_REPEAT_HPP_INCLUDED 37 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/benchmark/detail/catch_run_for_at_least.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | namespace Catch { 14 | namespace Benchmark { 15 | namespace Detail { 16 | struct optimized_away_error : std::exception { 17 | const char* what() const noexcept override; 18 | }; 19 | 20 | const char* optimized_away_error::what() const noexcept { 21 | return "could not measure benchmark, maybe it was optimized away"; 22 | } 23 | 24 | void throw_optimized_away_error() { 25 | Catch::throw_exception(optimized_away_error{}); 26 | } 27 | 28 | } // namespace Detail 29 | } // namespace Benchmark 30 | } // namespace Catch 31 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/benchmark/detail/catch_timing.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | // Adapted from donated nonius code. 9 | 10 | #ifndef CATCH_TIMING_HPP_INCLUDED 11 | #define CATCH_TIMING_HPP_INCLUDED 12 | 13 | #include 14 | #include 15 | 16 | #include 17 | 18 | namespace Catch { 19 | namespace Benchmark { 20 | template 21 | struct Timing { 22 | Duration elapsed; 23 | Result result; 24 | int iterations; 25 | }; 26 | template 27 | using TimingOf = Timing, Detail::CompleteType_t>>; 28 | } // namespace Benchmark 29 | } // namespace Catch 30 | 31 | #endif // CATCH_TIMING_HPP_INCLUDED 32 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/catch_assertion_info.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_ASSERTION_INFO_HPP_INCLUDED 9 | #define CATCH_ASSERTION_INFO_HPP_INCLUDED 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | namespace Catch { 16 | 17 | struct AssertionInfo { 18 | // AssertionInfo() = delete; 19 | 20 | StringRef macroName; 21 | SourceLineInfo lineInfo; 22 | StringRef capturedExpression; 23 | ResultDisposition::Flags resultDisposition; 24 | }; 25 | 26 | } // end namespace Catch 27 | 28 | #endif // CATCH_ASSERTION_INFO_HPP_INCLUDED 29 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/catch_tag_alias.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_TAG_ALIAS_HPP_INCLUDED 9 | #define CATCH_TAG_ALIAS_HPP_INCLUDED 10 | 11 | #include 12 | 13 | #include 14 | 15 | namespace Catch { 16 | 17 | struct TagAlias { 18 | TagAlias(std::string const& _tag, SourceLineInfo _lineInfo): 19 | tag(_tag), 20 | lineInfo(_lineInfo) 21 | {} 22 | 23 | std::string tag; 24 | SourceLineInfo lineInfo; 25 | }; 26 | 27 | } // end namespace Catch 28 | 29 | #endif // CATCH_TAG_ALIAS_HPP_INCLUDED 30 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/catch_tag_alias_autoregistrar.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | namespace Catch { 14 | 15 | RegistrarForTagAliases::RegistrarForTagAliases(char const* alias, char const* tag, SourceLineInfo const& lineInfo) { 16 | CATCH_TRY { 17 | getMutableRegistryHub().registerTagAlias(alias, tag, lineInfo); 18 | } CATCH_CATCH_ALL { 19 | // Do not throw when constructing global objects, instead register the exception to be processed later 20 | getMutableRegistryHub().registerStartupException(); 21 | } 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/catch_tag_alias_autoregistrar.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_TAG_ALIAS_AUTOREGISTRAR_HPP_INCLUDED 9 | #define CATCH_TAG_ALIAS_AUTOREGISTRAR_HPP_INCLUDED 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | namespace Catch { 16 | 17 | struct RegistrarForTagAliases { 18 | RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo ); 19 | }; 20 | 21 | } // end namespace Catch 22 | 23 | #define CATCH_REGISTER_TAG_ALIAS( alias, spec ) \ 24 | CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ 25 | CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ 26 | namespace{ Catch::RegistrarForTagAliases INTERNAL_CATCH_UNIQUE_NAME( AutoRegisterTagAlias )( alias, spec, CATCH_INTERNAL_LINEINFO ); } \ 27 | CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION 28 | 29 | #endif // CATCH_TAG_ALIAS_AUTOREGISTRAR_HPP_INCLUDED 30 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/catch_timer.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #include 9 | 10 | #include 11 | 12 | namespace Catch { 13 | 14 | namespace { 15 | static auto getCurrentNanosecondsSinceEpoch() -> uint64_t { 16 | return std::chrono::duration_cast(std::chrono::high_resolution_clock::now().time_since_epoch()).count(); 17 | } 18 | } // end unnamed namespace 19 | 20 | void Timer::start() { 21 | m_nanoseconds = getCurrentNanosecondsSinceEpoch(); 22 | } 23 | auto Timer::getElapsedNanoseconds() const -> uint64_t { 24 | return getCurrentNanosecondsSinceEpoch() - m_nanoseconds; 25 | } 26 | auto Timer::getElapsedMicroseconds() const -> uint64_t { 27 | return getElapsedNanoseconds()/1000; 28 | } 29 | auto Timer::getElapsedMilliseconds() const -> unsigned int { 30 | return static_cast(getElapsedMicroseconds()/1000); 31 | } 32 | auto Timer::getElapsedSeconds() const -> double { 33 | return getElapsedMicroseconds()/1000000.0; 34 | } 35 | 36 | 37 | } // namespace Catch 38 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/catch_timer.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_TIMER_HPP_INCLUDED 9 | #define CATCH_TIMER_HPP_INCLUDED 10 | 11 | #include 12 | 13 | namespace Catch { 14 | 15 | class Timer { 16 | uint64_t m_nanoseconds = 0; 17 | public: 18 | void start(); 19 | auto getElapsedNanoseconds() const -> uint64_t; 20 | auto getElapsedMicroseconds() const -> uint64_t; 21 | auto getElapsedMilliseconds() const -> unsigned int; 22 | auto getElapsedSeconds() const -> double; 23 | }; 24 | 25 | } // namespace Catch 26 | 27 | #endif // CATCH_TIMER_HPP_INCLUDED 28 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/catch_totals.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_TOTALS_HPP_INCLUDED 9 | #define CATCH_TOTALS_HPP_INCLUDED 10 | 11 | #include 12 | 13 | namespace Catch { 14 | 15 | struct Counts { 16 | Counts operator - ( Counts const& other ) const; 17 | Counts& operator += ( Counts const& other ); 18 | 19 | std::uint64_t total() const; 20 | bool allPassed() const; 21 | bool allOk() const; 22 | 23 | std::uint64_t passed = 0; 24 | std::uint64_t failed = 0; 25 | std::uint64_t failedButOk = 0; 26 | }; 27 | 28 | struct Totals { 29 | 30 | Totals operator - ( Totals const& other ) const; 31 | Totals& operator += ( Totals const& other ); 32 | 33 | Totals delta( Totals const& prevTotals ) const; 34 | 35 | Counts assertions; 36 | Counts testCases; 37 | }; 38 | } 39 | 40 | #endif // CATCH_TOTALS_HPP_INCLUDED 41 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/catch_version.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_VERSION_HPP_INCLUDED 9 | #define CATCH_VERSION_HPP_INCLUDED 10 | 11 | #include 12 | 13 | namespace Catch { 14 | 15 | // Versioning information 16 | struct Version { 17 | Version( Version const& ) = delete; 18 | Version& operator=( Version const& ) = delete; 19 | Version( unsigned int _majorVersion, 20 | unsigned int _minorVersion, 21 | unsigned int _patchNumber, 22 | char const * const _branchName, 23 | unsigned int _buildNumber ); 24 | 25 | unsigned int const majorVersion; 26 | unsigned int const minorVersion; 27 | unsigned int const patchNumber; 28 | 29 | // buildNumber is only used if branchName is not null 30 | char const * const branchName; 31 | unsigned int const buildNumber; 32 | 33 | friend std::ostream& operator << ( std::ostream& os, Version const& version ); 34 | }; 35 | 36 | Version const& libraryVersion(); 37 | } 38 | 39 | #endif // CATCH_VERSION_HPP_INCLUDED 40 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/catch_version_macros.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_VERSION_MACROS_HPP_INCLUDED 9 | #define CATCH_VERSION_MACROS_HPP_INCLUDED 10 | 11 | #define CATCH_VERSION_MAJOR 3 12 | #define CATCH_VERSION_MINOR 1 13 | #define CATCH_VERSION_PATCH 0 14 | 15 | #endif // CATCH_VERSION_MACROS_HPP_INCLUDED 16 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/generators/catch_generator_exception.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | namespace Catch { 12 | 13 | const char* GeneratorException::what() const noexcept { 14 | return m_msg; 15 | } 16 | 17 | } // end namespace Catch 18 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/generators/catch_generator_exception.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_GENERATOR_EXCEPTION_HPP_INCLUDED 9 | #define CATCH_GENERATOR_EXCEPTION_HPP_INCLUDED 10 | 11 | #include 12 | 13 | namespace Catch { 14 | 15 | // Exception type to be thrown when a Generator runs into an error, 16 | // e.g. it cannot initialize the first return value based on 17 | // runtime information 18 | class GeneratorException : public std::exception { 19 | const char* const m_msg = ""; 20 | 21 | public: 22 | GeneratorException(const char* msg): 23 | m_msg(msg) 24 | {} 25 | 26 | const char* what() const noexcept override final; 27 | }; 28 | 29 | } // end namespace Catch 30 | 31 | #endif // CATCH_GENERATOR_EXCEPTION_HPP_INCLUDED 32 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/generators/catch_generators.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | namespace Catch { 15 | 16 | IGeneratorTracker::~IGeneratorTracker() = default; 17 | 18 | namespace Generators { 19 | 20 | namespace Detail { 21 | 22 | [[noreturn]] 23 | void throw_generator_exception(char const* msg) { 24 | Catch::throw_exception(GeneratorException{ msg }); 25 | } 26 | } // end namespace Detail 27 | 28 | GeneratorUntypedBase::~GeneratorUntypedBase() = default; 29 | 30 | auto acquireGeneratorTracker(StringRef generatorName, SourceLineInfo const& lineInfo ) -> IGeneratorTracker& { 31 | return getResultCapture().acquireGeneratorTracker( generatorName, lineInfo ); 32 | } 33 | 34 | } // namespace Generators 35 | } // namespace Catch 36 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/generators/catch_generators_all.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | /** \file 9 | * This is a convenience header for Catch2's Generator support. It includes 10 | * **all** of Catch2 headers related to generators. 11 | * 12 | * Generally the Catch2 users should use specific includes they need, 13 | * but this header can be used instead for ease-of-experimentation, or 14 | * just plain convenience, at the cost of (significantly) increased 15 | * compilation times. 16 | * 17 | * When a new header is added to either the `generators` folder, 18 | * or to the corresponding internal subfolder, it should be added here. 19 | */ 20 | 21 | #ifndef CATCH_GENERATORS_ALL_HPP_INCLUDED 22 | #define CATCH_GENERATORS_ALL_HPP_INCLUDED 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #endif // CATCH_GENERATORS_ALL_HPP_INCLUDED 31 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/generators/catch_generators_random.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | #include 12 | 13 | std::uint32_t Catch::Generators::Detail::getSeed() { return sharedRng()(); } 14 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/interfaces/catch_interfaces_capture.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | namespace Catch { 12 | IResultCapture::~IResultCapture() = default; 13 | } 14 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/interfaces/catch_interfaces_config.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | namespace Catch { 12 | IConfig::~IConfig() = default; 13 | } 14 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/interfaces/catch_interfaces_exception.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | namespace Catch { 12 | IExceptionTranslator::~IExceptionTranslator() = default; 13 | IExceptionTranslatorRegistry::~IExceptionTranslatorRegistry() = default; 14 | } 15 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/interfaces/catch_interfaces_exception.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_INTERFACES_EXCEPTION_HPP_INCLUDED 9 | #define CATCH_INTERFACES_EXCEPTION_HPP_INCLUDED 10 | 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | 17 | namespace Catch { 18 | using exceptionTranslateFunction = std::string(*)(); 19 | 20 | class IExceptionTranslator; 21 | using ExceptionTranslators = std::vector>; 22 | 23 | class IExceptionTranslator { 24 | public: 25 | virtual ~IExceptionTranslator(); // = default 26 | virtual std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const = 0; 27 | }; 28 | 29 | class IExceptionTranslatorRegistry { 30 | public: 31 | virtual ~IExceptionTranslatorRegistry(); // = default 32 | virtual std::string translateActiveException() const = 0; 33 | }; 34 | 35 | } // namespace Catch 36 | 37 | #endif // CATCH_INTERFACES_EXCEPTION_HPP_INCLUDED 38 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/interfaces/catch_interfaces_generatortracker.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | #include 11 | 12 | namespace Catch { 13 | namespace Generators { 14 | 15 | bool GeneratorUntypedBase::countedNext() { 16 | auto ret = next(); 17 | if ( ret ) { 18 | m_stringReprCache.clear(); 19 | ++m_currentElementIndex; 20 | } 21 | return ret; 22 | } 23 | 24 | StringRef GeneratorUntypedBase::currentElementAsString() const { 25 | if ( m_stringReprCache.empty() ) { 26 | m_stringReprCache = stringifyImpl(); 27 | } 28 | return m_stringReprCache; 29 | } 30 | 31 | } // namespace Generators 32 | } // namespace Catch 33 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/interfaces/catch_interfaces_registry_hub.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | namespace Catch { 12 | IRegistryHub::~IRegistryHub() = default; 13 | IMutableRegistryHub::~IMutableRegistryHub() = default; 14 | } 15 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/interfaces/catch_interfaces_reporter_factory.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | namespace Catch { 12 | IReporterFactory::~IReporterFactory() = default; 13 | EventListenerFactory::~EventListenerFactory() = default; 14 | } 15 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/interfaces/catch_interfaces_reporter_registry.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | namespace Catch { 12 | IReporterRegistry::~IReporterRegistry() = default; 13 | } 14 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/interfaces/catch_interfaces_tag_alias_registry.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_INTERFACES_TAG_ALIAS_REGISTRY_HPP_INCLUDED 9 | #define CATCH_INTERFACES_TAG_ALIAS_REGISTRY_HPP_INCLUDED 10 | 11 | #include 12 | 13 | namespace Catch { 14 | 15 | struct TagAlias; 16 | 17 | class ITagAliasRegistry { 18 | public: 19 | virtual ~ITagAliasRegistry(); // = default 20 | // Nullptr if not present 21 | virtual TagAlias const* find( std::string const& alias ) const = 0; 22 | virtual std::string expandAliases( std::string const& unexpandedTestSpec ) const = 0; 23 | 24 | static ITagAliasRegistry const& get(); 25 | }; 26 | 27 | } // end namespace Catch 28 | 29 | #endif // CATCH_INTERFACES_TAG_ALIAS_REGISTRY_HPP_INCLUDED 30 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/interfaces/catch_interfaces_testcase.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | namespace Catch { 12 | ITestInvoker::~ITestInvoker() = default; 13 | ITestCaseRegistry::~ITestCaseRegistry() = default; 14 | } 15 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_case_insensitive_comparisons.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | #include 11 | 12 | #include 13 | 14 | namespace Catch { 15 | namespace Detail { 16 | 17 | bool CaseInsensitiveLess::operator()( StringRef lhs, 18 | StringRef rhs ) const { 19 | return std::lexicographical_compare( 20 | lhs.begin(), lhs.end(), 21 | rhs.begin(), rhs.end(), 22 | []( char l, char r ) { return toLower( l ) < toLower( r ); } ); 23 | } 24 | 25 | bool 26 | CaseInsensitiveEqualTo::operator()( StringRef lhs, 27 | StringRef rhs ) const { 28 | return std::equal( 29 | lhs.begin(), lhs.end(), 30 | rhs.begin(), rhs.end(), 31 | []( char l, char r ) { return toLower( l ) == toLower( r ); } ); 32 | } 33 | 34 | } // namespace Detail 35 | } // namespace Catch 36 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_case_insensitive_comparisons.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_CASE_INSENSITIVE_COMPARISONS_HPP_INCLUDED 9 | #define CATCH_CASE_INSENSITIVE_COMPARISONS_HPP_INCLUDED 10 | 11 | #include 12 | 13 | namespace Catch { 14 | namespace Detail { 15 | //! Provides case-insensitive `op<` semantics when called 16 | struct CaseInsensitiveLess { 17 | bool operator()( StringRef lhs, 18 | StringRef rhs ) const; 19 | }; 20 | 21 | //! Provides case-insensitive `op==` semantics when called 22 | struct CaseInsensitiveEqualTo { 23 | bool operator()( StringRef lhs, 24 | StringRef rhs ) const; 25 | }; 26 | 27 | } // namespace Detail 28 | } // namespace Catch 29 | 30 | #endif // CATCH_CASE_INSENSITIVE_COMPARISONS_HPP_INCLUDED 31 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_case_sensitive.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_CASE_SENSITIVE_HPP_INCLUDED 9 | #define CATCH_CASE_SENSITIVE_HPP_INCLUDED 10 | 11 | namespace Catch { 12 | 13 | enum class CaseSensitive { Yes, No }; 14 | 15 | } // namespace Catch 16 | 17 | #endif // CATCH_CASE_SENSITIVE_HPP_INCLUDED 18 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_commandline.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_COMMANDLINE_HPP_INCLUDED 9 | #define CATCH_COMMANDLINE_HPP_INCLUDED 10 | 11 | #include 12 | 13 | namespace Catch { 14 | 15 | struct ConfigData; 16 | 17 | Clara::Parser makeCommandLineParser( ConfigData& config ); 18 | 19 | } // end namespace Catch 20 | 21 | #endif // CATCH_COMMANDLINE_HPP_INCLUDED 22 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_config_android_logwrite.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | /** \file 10 | * Wrapper for ANDROID_LOGWRITE configuration option 11 | * 12 | * We want to default to enabling it when compiled for android, but 13 | * users of the library should also be able to disable it if they want 14 | * to. 15 | */ 16 | 17 | #ifndef CATCH_CONFIG_ANDROID_LOGWRITE_HPP_INCLUDED 18 | #define CATCH_CONFIG_ANDROID_LOGWRITE_HPP_INCLUDED 19 | 20 | #include 21 | 22 | #if defined(__ANDROID__) 23 | # define CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE 24 | #endif 25 | 26 | 27 | #if defined( CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE ) && \ 28 | !defined( CATCH_CONFIG_NO_ANDROID_LOGWRITE ) && \ 29 | !defined( CATCH_CONFIG_ANDROID_LOGWRITE ) 30 | # define CATCH_CONFIG_ANDROID_LOGWRITE 31 | #endif 32 | 33 | #endif // CATCH_CONFIG_ANDROID_LOGWRITE_HPP_INCLUDED 34 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_config_counter.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | /** \file 10 | * Wrapper for the CONFIG configuration option 11 | * 12 | * When generating internal unique names, there are two options. Either 13 | * we mix in the current line number, or mix in an incrementing number. 14 | * We prefer the latter, using `__COUNTER__`, but users might want to 15 | * use the former. 16 | */ 17 | 18 | #ifndef CATCH_CONFIG_COUNTER_HPP_INCLUDED 19 | #define CATCH_CONFIG_COUNTER_HPP_INCLUDED 20 | 21 | #if ( !defined(__JETBRAINS_IDE__) || __JETBRAINS_IDE__ >= 20170300L ) 22 | #define CATCH_INTERNAL_CONFIG_COUNTER 23 | #endif 24 | 25 | #if defined( CATCH_INTERNAL_CONFIG_COUNTER ) && \ 26 | !defined( CATCH_CONFIG_NO_COUNTER ) && \ 27 | !defined( CATCH_CONFIG_COUNTER ) 28 | # define CATCH_CONFIG_COUNTER 29 | #endif 30 | 31 | 32 | #endif // CATCH_CONFIG_COUNTER_HPP_INCLUDED 33 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_config_wchar.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | /** \file 10 | * Wrapper for the WCHAR configuration option 11 | * 12 | * We want to support platforms that do not provide `wchar_t`, so we 13 | * sometimes have to disable providing wchar_t overloads through Catch2, 14 | * e.g. the StringMaker specialization for `std::wstring`. 15 | */ 16 | 17 | #ifndef CATCH_CONFIG_WCHAR_HPP_INCLUDED 18 | #define CATCH_CONFIG_WCHAR_HPP_INCLUDED 19 | 20 | // We assume that WCHAR should be enabled by default, and only disabled 21 | // for a shortlist (so far only DJGPP) of compilers. 22 | 23 | #if defined(__DJGPP__) 24 | # define CATCH_INTERNAL_CONFIG_NO_WCHAR 25 | #endif // __DJGPP__ 26 | 27 | #if !defined( CATCH_INTERNAL_CONFIG_NO_WCHAR ) && \ 28 | !defined( CATCH_CONFIG_NO_WCHAR ) && \ 29 | !defined( CATCH_CONFIG_WCHAR ) 30 | # define CATCH_CONFIG_WCHAR 31 | #endif 32 | 33 | #endif // CATCH_CONFIG_WCHAR_HPP_INCLUDED 34 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_console_width.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_CONSOLE_WIDTH_HPP_INCLUDED 9 | #define CATCH_CONSOLE_WIDTH_HPP_INCLUDED 10 | 11 | // This include must be kept so that user's configured value for CONSOLE_WIDTH 12 | // is used before we attempt to provide a default value 13 | #include 14 | 15 | #ifndef CATCH_CONFIG_CONSOLE_WIDTH 16 | #define CATCH_CONFIG_CONSOLE_WIDTH 80 17 | #endif 18 | 19 | #endif // CATCH_CONSOLE_WIDTH_HPP_INCLUDED 20 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_debug_console.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_DEBUG_CONSOLE_HPP_INCLUDED 9 | #define CATCH_DEBUG_CONSOLE_HPP_INCLUDED 10 | 11 | #include 12 | 13 | namespace Catch { 14 | void writeToDebugConsole( std::string const& text ); 15 | } 16 | 17 | #endif // CATCH_DEBUG_CONSOLE_HPP_INCLUDED 18 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_decomposer.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | namespace Catch { 12 | 13 | ITransientExpression::~ITransientExpression() = default; 14 | 15 | void formatReconstructedExpression( std::ostream &os, std::string const& lhs, StringRef op, std::string const& rhs ) { 16 | if( lhs.size() + rhs.size() < 40 && 17 | lhs.find('\n') == std::string::npos && 18 | rhs.find('\n') == std::string::npos ) 19 | os << lhs << ' ' << op << ' ' << rhs; 20 | else 21 | os << lhs << '\n' << op << '\n' << rhs; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_enforce.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | 14 | namespace Catch { 15 | #if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) && !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS_CUSTOM_HANDLER) 16 | [[noreturn]] 17 | void throw_exception(std::exception const& e) { 18 | Catch::cerr() << "Catch will terminate because it needed to throw an exception.\n" 19 | << "The message was: " << e.what() << '\n'; 20 | std::terminate(); 21 | } 22 | #endif 23 | 24 | [[noreturn]] 25 | void throw_logic_error(std::string const& msg) { 26 | throw_exception(std::logic_error(msg)); 27 | } 28 | 29 | [[noreturn]] 30 | void throw_domain_error(std::string const& msg) { 31 | throw_exception(std::domain_error(msg)); 32 | } 33 | 34 | [[noreturn]] 35 | void throw_runtime_error(std::string const& msg) { 36 | throw_exception(std::runtime_error(msg)); 37 | } 38 | 39 | 40 | 41 | } // namespace Catch; 42 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_enum_values_registry.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_ENUM_VALUES_REGISTRY_HPP_INCLUDED 9 | #define CATCH_ENUM_VALUES_REGISTRY_HPP_INCLUDED 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | namespace Catch { 18 | 19 | namespace Detail { 20 | 21 | Catch::Detail::unique_ptr makeEnumInfo( StringRef enumName, StringRef allValueNames, std::vector const& values ); 22 | 23 | class EnumValuesRegistry : public IMutableEnumValuesRegistry { 24 | 25 | std::vector> m_enumInfos; 26 | 27 | EnumInfo const& registerEnum( StringRef enumName, StringRef allEnums, std::vector const& values) override; 28 | }; 29 | 30 | std::vector parseEnums( StringRef enums ); 31 | 32 | } // Detail 33 | 34 | } // Catch 35 | 36 | #endif // CATCH_ENUM_VALUES_REGISTRY_HPP_INCLUDED 37 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_errno_guard.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | #include 12 | 13 | namespace Catch { 14 | ErrnoGuard::ErrnoGuard():m_oldErrno(errno){} 15 | ErrnoGuard::~ErrnoGuard() { errno = m_oldErrno; } 16 | } 17 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_errno_guard.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_ERRNO_GUARD_HPP_INCLUDED 9 | #define CATCH_ERRNO_GUARD_HPP_INCLUDED 10 | 11 | namespace Catch { 12 | 13 | //! Simple RAII class that stores the value of `errno` 14 | //! at construction and restores it at destruction. 15 | class ErrnoGuard { 16 | public: 17 | // Keep these outlined to avoid dragging in macros from 18 | 19 | ErrnoGuard(); 20 | ~ErrnoGuard(); 21 | private: 22 | int m_oldErrno; 23 | }; 24 | 25 | } 26 | 27 | #endif // CATCH_ERRNO_GUARD_HPP_INCLUDED 28 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_exception_translator_registry.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_EXCEPTION_TRANSLATOR_REGISTRY_HPP_INCLUDED 9 | #define CATCH_EXCEPTION_TRANSLATOR_REGISTRY_HPP_INCLUDED 10 | 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | 17 | namespace Catch { 18 | 19 | class ExceptionTranslatorRegistry : public IExceptionTranslatorRegistry { 20 | public: 21 | ~ExceptionTranslatorRegistry() override; 22 | void registerTranslator( Detail::unique_ptr&& translator ); 23 | std::string translateActiveException() const override; 24 | std::string tryTranslators() const; 25 | 26 | private: 27 | ExceptionTranslators m_translators; 28 | }; 29 | } 30 | 31 | #endif // CATCH_EXCEPTION_TRANSLATOR_REGISTRY_HPP_INCLUDED 32 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_floating_point_helpers.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | #include 12 | 13 | namespace Catch { 14 | namespace Detail { 15 | 16 | uint32_t convertToBits(float f) { 17 | static_assert(sizeof(float) == sizeof(uint32_t), "Important ULP matcher assumption violated"); 18 | uint32_t i; 19 | std::memcpy(&i, &f, sizeof(f)); 20 | return i; 21 | } 22 | 23 | uint64_t convertToBits(double d) { 24 | static_assert(sizeof(double) == sizeof(uint64_t), "Important ULP matcher assumption violated"); 25 | uint64_t i; 26 | std::memcpy(&i, &d, sizeof(d)); 27 | return i; 28 | } 29 | 30 | } // end namespace Detail 31 | } // end namespace Catch 32 | 33 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_lazy_expr.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | #include 11 | 12 | namespace Catch { 13 | 14 | auto operator << (std::ostream& os, LazyExpression const& lazyExpr) -> std::ostream& { 15 | if (lazyExpr.m_isNegated) 16 | os << '!'; 17 | 18 | if (lazyExpr) { 19 | if (lazyExpr.m_isNegated && lazyExpr.m_transientExpression->isBinaryExpression()) 20 | os << '(' << *lazyExpr.m_transientExpression << ')'; 21 | else 22 | os << *lazyExpr.m_transientExpression; 23 | } else { 24 | os << "{** error - unchecked empty expression requested **}"; 25 | } 26 | return os; 27 | } 28 | 29 | } // namespace Catch 30 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_lazy_expr.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_LAZY_EXPR_HPP_INCLUDED 9 | #define CATCH_LAZY_EXPR_HPP_INCLUDED 10 | 11 | #include 12 | 13 | namespace Catch { 14 | 15 | class ITransientExpression; 16 | 17 | class LazyExpression { 18 | friend class AssertionHandler; 19 | friend struct AssertionStats; 20 | friend class RunContext; 21 | 22 | ITransientExpression const* m_transientExpression = nullptr; 23 | bool m_isNegated; 24 | public: 25 | LazyExpression( bool isNegated ): 26 | m_isNegated(isNegated) 27 | {} 28 | LazyExpression(LazyExpression const& other) = default; 29 | LazyExpression& operator = ( LazyExpression const& ) = delete; 30 | 31 | explicit operator bool() const { 32 | return m_transientExpression != nullptr; 33 | } 34 | 35 | friend auto operator << ( std::ostream& os, LazyExpression const& lazyExpr ) -> std::ostream&; 36 | }; 37 | 38 | } // namespace Catch 39 | 40 | #endif // CATCH_LAZY_EXPR_HPP_INCLUDED 41 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_leak_detector.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #ifdef CATCH_CONFIG_WINDOWS_CRTDBG 14 | #include 15 | 16 | namespace Catch { 17 | 18 | LeakDetector::LeakDetector() { 19 | int flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); 20 | flag |= _CRTDBG_LEAK_CHECK_DF; 21 | flag |= _CRTDBG_ALLOC_MEM_DF; 22 | _CrtSetDbgFlag(flag); 23 | _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG); 24 | _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); 25 | // Change this to leaking allocation's number to break there 26 | _CrtSetBreakAlloc(-1); 27 | } 28 | } 29 | 30 | #else // ^^ Windows crt debug heap enabled // Windows crt debug heap disabled vv 31 | 32 | Catch::LeakDetector::LeakDetector() {} 33 | 34 | #endif // CATCH_CONFIG_WINDOWS_CRTDBG 35 | 36 | Catch::LeakDetector::~LeakDetector() { 37 | Catch::cleanUp(); 38 | } 39 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_leak_detector.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_LEAK_DETECTOR_HPP_INCLUDED 9 | #define CATCH_LEAK_DETECTOR_HPP_INCLUDED 10 | 11 | namespace Catch { 12 | 13 | struct LeakDetector { 14 | LeakDetector(); 15 | ~LeakDetector(); 16 | }; 17 | 18 | } 19 | #endif // CATCH_LEAK_DETECTOR_HPP_INCLUDED 20 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_list.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_LIST_HPP_INCLUDED 9 | #define CATCH_LIST_HPP_INCLUDED 10 | 11 | #include 12 | 13 | #include 14 | #include 15 | 16 | 17 | namespace Catch { 18 | 19 | class IEventListener; 20 | class Config; 21 | 22 | 23 | struct ReporterDescription { 24 | std::string name, description; 25 | }; 26 | struct ListenerDescription { 27 | StringRef name; 28 | std::string description; 29 | }; 30 | 31 | struct TagInfo { 32 | void add(StringRef spelling); 33 | std::string all() const; 34 | 35 | std::set spellings; 36 | std::size_t count = 0; 37 | }; 38 | 39 | bool list( IEventListener& reporter, Config const& config ); 40 | 41 | } // end namespace Catch 42 | 43 | #endif // CATCH_LIST_HPP_INCLUDED 44 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_message_info.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | namespace Catch { 12 | 13 | MessageInfo::MessageInfo( StringRef _macroName, 14 | SourceLineInfo const& _lineInfo, 15 | ResultWas::OfType _type ) 16 | : macroName( _macroName ), 17 | lineInfo( _lineInfo ), 18 | type( _type ), 19 | sequence( ++globalCount ) 20 | {} 21 | 22 | // This may need protecting if threading support is added 23 | unsigned int MessageInfo::globalCount = 0; 24 | 25 | } // end namespace Catch 26 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_move_and_forward.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_MOVE_AND_FORWARD_HPP_INCLUDED 9 | #define CATCH_MOVE_AND_FORWARD_HPP_INCLUDED 10 | 11 | #include 12 | 13 | //! Replacement for std::move with better compile time performance 14 | #define CATCH_MOVE(...) static_cast&&>(__VA_ARGS__) 15 | 16 | //! Replacement for std::forward with better compile time performance 17 | #define CATCH_FORWARD(...) static_cast(__VA_ARGS__) 18 | 19 | #endif // CATCH_MOVE_AND_FORWARD_HPP_INCLUDED 20 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_noncopyable.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_NONCOPYABLE_HPP_INCLUDED 9 | #define CATCH_NONCOPYABLE_HPP_INCLUDED 10 | 11 | namespace Catch { 12 | namespace Detail { 13 | 14 | //! Deriving classes become noncopyable and nonmovable 15 | class NonCopyable { 16 | NonCopyable( NonCopyable const& ) = delete; 17 | NonCopyable( NonCopyable&& ) = delete; 18 | NonCopyable& operator=( NonCopyable const& ) = delete; 19 | NonCopyable& operator=( NonCopyable&& ) = delete; 20 | 21 | protected: 22 | NonCopyable() noexcept = default; 23 | }; 24 | 25 | } // namespace Detail 26 | } // namespace Catch 27 | 28 | #endif // CATCH_NONCOPYABLE_HPP_INCLUDED 29 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_platform.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_PLATFORM_HPP_INCLUDED 9 | #define CATCH_PLATFORM_HPP_INCLUDED 10 | 11 | // See e.g.: 12 | // https://opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/TargetConditionals.h.auto.html 13 | #ifdef __APPLE__ 14 | # include 15 | # if (defined(TARGET_OS_OSX) && TARGET_OS_OSX == 1) || \ 16 | (defined(TARGET_OS_MAC) && TARGET_OS_MAC == 1) 17 | # define CATCH_PLATFORM_MAC 18 | # elif (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE == 1) 19 | # define CATCH_PLATFORM_IPHONE 20 | # endif 21 | 22 | #elif defined(linux) || defined(__linux) || defined(__linux__) 23 | # define CATCH_PLATFORM_LINUX 24 | 25 | #elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) || defined(__MINGW32__) 26 | # define CATCH_PLATFORM_WINDOWS 27 | #endif 28 | 29 | #endif // CATCH_PLATFORM_HPP_INCLUDED 30 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_polyfills.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | namespace Catch { 16 | 17 | #if !defined(CATCH_CONFIG_POLYFILL_ISNAN) 18 | bool isnan(float f) { 19 | return std::isnan(f); 20 | } 21 | bool isnan(double d) { 22 | return std::isnan(d); 23 | } 24 | #else 25 | // For now we only use this for embarcadero 26 | bool isnan(float f) { 27 | return std::_isnan(f); 28 | } 29 | bool isnan(double d) { 30 | return std::_isnan(d); 31 | } 32 | #endif 33 | 34 | } // end namespace Catch 35 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_polyfills.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_POLYFILLS_HPP_INCLUDED 9 | #define CATCH_POLYFILLS_HPP_INCLUDED 10 | 11 | namespace Catch { 12 | bool isnan(float f); 13 | bool isnan(double d); 14 | } 15 | 16 | #endif // CATCH_POLYFILLS_HPP_INCLUDED 17 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_preprocessor_remove_parens.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_PREPROCESSOR_REMOVE_PARENS_HPP_INCLUDED 9 | #define CATCH_PREPROCESSOR_REMOVE_PARENS_HPP_INCLUDED 10 | 11 | #define INTERNAL_CATCH_EXPAND1( param ) INTERNAL_CATCH_EXPAND2( param ) 12 | #define INTERNAL_CATCH_EXPAND2( ... ) INTERNAL_CATCH_NO##__VA_ARGS__ 13 | #define INTERNAL_CATCH_DEF( ... ) INTERNAL_CATCH_DEF __VA_ARGS__ 14 | #define INTERNAL_CATCH_NOINTERNAL_CATCH_DEF 15 | 16 | #define INTERNAL_CATCH_REMOVE_PARENS( ... ) \ 17 | INTERNAL_CATCH_EXPAND1( INTERNAL_CATCH_DEF __VA_ARGS__ ) 18 | 19 | #endif // CATCH_PREPROCESSOR_REMOVE_PARENS_HPP_INCLUDED 20 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_random_seed_generation.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | #include 12 | 13 | #include 14 | #include 15 | 16 | namespace Catch { 17 | 18 | std::uint32_t generateRandomSeed( GenerateFrom from ) { 19 | switch ( from ) { 20 | case GenerateFrom::Time: 21 | return static_cast( std::time( nullptr ) ); 22 | 23 | case GenerateFrom::Default: 24 | case GenerateFrom::RandomDevice: 25 | // In theory, a platform could have random_device that returns just 26 | // 16 bits. That is still some randomness, so we don't care too much 27 | return static_cast( std::random_device{}() ); 28 | 29 | default: 30 | CATCH_ERROR("Unknown generation method"); 31 | } 32 | } 33 | 34 | } // end namespace Catch 35 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_random_seed_generation.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_RANDOM_SEED_GENERATION_HPP_INCLUDED 9 | #define CATCH_RANDOM_SEED_GENERATION_HPP_INCLUDED 10 | 11 | #include 12 | 13 | namespace Catch { 14 | 15 | enum class GenerateFrom { 16 | Time, 17 | RandomDevice, 18 | //! Currently equivalent to RandomDevice, but can change at any point 19 | Default 20 | }; 21 | 22 | std::uint32_t generateRandomSeed(GenerateFrom from); 23 | 24 | } // end namespace Catch 25 | 26 | #endif // CATCH_RANDOM_SEED_GENERATION_HPP_INCLUDED 27 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_reporter_registry.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_REPORTER_REGISTRY_HPP_INCLUDED 9 | #define CATCH_REPORTER_REGISTRY_HPP_INCLUDED 10 | 11 | #include 12 | #include 13 | 14 | #include 15 | 16 | namespace Catch { 17 | 18 | class ReporterRegistry : public IReporterRegistry { 19 | public: 20 | 21 | ReporterRegistry(); 22 | ~ReporterRegistry() override; // = default, out of line to allow fwd decl 23 | 24 | IEventListenerPtr create( std::string const& name, ReporterConfig&& config ) const override; 25 | 26 | void registerReporter( std::string const& name, IReporterFactoryPtr factory ); 27 | void registerListener( Detail::unique_ptr factory ); 28 | 29 | FactoryMap const& getFactories() const override; 30 | Listeners const& getListeners() const override; 31 | 32 | private: 33 | FactoryMap m_factories; 34 | Listeners m_listeners; 35 | }; 36 | } 37 | 38 | #endif // CATCH_REPORTER_REGISTRY_HPP_INCLUDED 39 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_result_type.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #include 9 | 10 | namespace Catch { 11 | 12 | bool isOk( ResultWas::OfType resultType ) { 13 | return ( resultType & ResultWas::FailureBit ) == 0; 14 | } 15 | bool isJustInfo( int flags ) { 16 | return flags == ResultWas::Info; 17 | } 18 | 19 | ResultDisposition::Flags operator | ( ResultDisposition::Flags lhs, ResultDisposition::Flags rhs ) { 20 | return static_cast( static_cast( lhs ) | static_cast( rhs ) ); 21 | } 22 | 23 | bool shouldContinueOnFailure( int flags ) { return ( flags & ResultDisposition::ContinueOnFailure ) != 0; } 24 | bool shouldSuppressFailure( int flags ) { return ( flags & ResultDisposition::SuppressFail ) != 0; } 25 | 26 | } // end namespace Catch 27 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_singletons.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #include 9 | 10 | #include 11 | 12 | namespace Catch { 13 | 14 | namespace { 15 | static auto getSingletons() -> std::vector*& { 16 | static std::vector* g_singletons = nullptr; 17 | if( !g_singletons ) 18 | g_singletons = new std::vector(); 19 | return g_singletons; 20 | } 21 | } 22 | 23 | ISingleton::~ISingleton() = default; 24 | 25 | void addSingleton(ISingleton* singleton ) { 26 | getSingletons()->push_back( singleton ); 27 | } 28 | void cleanupSingletons() { 29 | auto& singletons = getSingletons(); 30 | for( auto singleton : *singletons ) 31 | delete singleton; 32 | delete singletons; 33 | singletons = nullptr; 34 | } 35 | 36 | } // namespace Catch 37 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_source_line_info.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | namespace Catch { 14 | 15 | bool SourceLineInfo::operator == ( SourceLineInfo const& other ) const noexcept { 16 | return line == other.line && (file == other.file || std::strcmp(file, other.file) == 0); 17 | } 18 | bool SourceLineInfo::operator < ( SourceLineInfo const& other ) const noexcept { 19 | // We can assume that the same file will usually have the same pointer. 20 | // Thus, if the pointers are the same, there is no point in calling the strcmp 21 | return line < other.line || ( line == other.line && file != other.file && (std::strcmp(file, other.file) < 0)); 22 | } 23 | 24 | std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ) { 25 | #ifndef __GNUG__ 26 | os << info.file << '(' << info.line << ')'; 27 | #else 28 | os << info.file << ':' << info.line; 29 | #endif 30 | return os; 31 | } 32 | 33 | } // end namespace Catch 34 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_source_line_info.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_SOURCE_LINE_INFO_HPP_INCLUDED 9 | #define CATCH_SOURCE_LINE_INFO_HPP_INCLUDED 10 | 11 | #include 12 | #include 13 | 14 | namespace Catch { 15 | 16 | struct SourceLineInfo { 17 | 18 | SourceLineInfo() = delete; 19 | constexpr SourceLineInfo( char const* _file, std::size_t _line ) noexcept: 20 | file( _file ), 21 | line( _line ) 22 | {} 23 | 24 | bool operator == ( SourceLineInfo const& other ) const noexcept; 25 | bool operator < ( SourceLineInfo const& other ) const noexcept; 26 | 27 | char const* file; 28 | std::size_t line; 29 | 30 | friend std::ostream& operator << (std::ostream& os, SourceLineInfo const& info); 31 | }; 32 | } 33 | 34 | #define CATCH_INTERNAL_LINEINFO \ 35 | ::Catch::SourceLineInfo( __FILE__, static_cast( __LINE__ ) ) 36 | 37 | #endif // CATCH_SOURCE_LINE_INFO_HPP_INCLUDED 38 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_startup_exception_registry.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | namespace Catch { 14 | #if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) 15 | void StartupExceptionRegistry::add( std::exception_ptr const& exception ) noexcept { 16 | CATCH_TRY { 17 | m_exceptions.push_back(exception); 18 | } CATCH_CATCH_ALL { 19 | // If we run out of memory during start-up there's really not a lot more we can do about it 20 | std::terminate(); 21 | } 22 | } 23 | 24 | std::vector const& StartupExceptionRegistry::getExceptions() const noexcept { 25 | return m_exceptions; 26 | } 27 | #endif 28 | 29 | } // end namespace Catch 30 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_startup_exception_registry.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_STARTUP_EXCEPTION_REGISTRY_HPP_INCLUDED 9 | #define CATCH_STARTUP_EXCEPTION_REGISTRY_HPP_INCLUDED 10 | 11 | 12 | #include 13 | #include 14 | 15 | namespace Catch { 16 | 17 | class StartupExceptionRegistry { 18 | #if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) 19 | public: 20 | void add(std::exception_ptr const& exception) noexcept; 21 | std::vector const& getExceptions() const noexcept; 22 | private: 23 | std::vector m_exceptions; 24 | #endif 25 | }; 26 | 27 | } // end namespace Catch 28 | 29 | #endif // CATCH_STARTUP_EXCEPTION_REGISTRY_HPP_INCLUDED 30 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_stdstreams.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | #include 12 | 13 | #include 14 | 15 | namespace Catch { 16 | 17 | // If you #define this you must implement these functions 18 | #if !defined( CATCH_CONFIG_NOSTDOUT ) 19 | std::ostream& cout() { return std::cout; } 20 | std::ostream& cerr() { return std::cerr; } 21 | std::ostream& clog() { return std::clog; } 22 | #endif 23 | 24 | } // namespace Catch 25 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_stdstreams.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #ifndef CATCH_STDSTREAMS_HPP_INCLUDED 10 | #define CATCH_STDSTREAMS_HPP_INCLUDED 11 | 12 | #include 13 | 14 | namespace Catch { 15 | 16 | std::ostream& cout(); 17 | std::ostream& cerr(); 18 | std::ostream& clog(); 19 | 20 | } // namespace Catch 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_stream_end_stop.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_STREAM_END_STOP_HPP_INCLUDED 9 | #define CATCH_STREAM_END_STOP_HPP_INCLUDED 10 | 11 | #include 12 | 13 | namespace Catch { 14 | 15 | // Use this in variadic streaming macros to allow 16 | // << +StreamEndStop 17 | // as well as 18 | // << stuff +StreamEndStop 19 | struct StreamEndStop { 20 | StringRef operator+() const { return StringRef(); } 21 | 22 | template 23 | friend T const& operator+( T const& value, StreamEndStop ) { 24 | return value; 25 | } 26 | }; 27 | 28 | } // namespace Catch 29 | 30 | #endif // CATCH_STREAM_END_STOP_HPP_INCLUDED 31 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_tag_alias_registry.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_TAG_ALIAS_REGISTRY_HPP_INCLUDED 9 | #define CATCH_TAG_ALIAS_REGISTRY_HPP_INCLUDED 10 | 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | 17 | namespace Catch { 18 | struct SourceLineInfo; 19 | 20 | class TagAliasRegistry : public ITagAliasRegistry { 21 | public: 22 | ~TagAliasRegistry() override; 23 | TagAlias const* find( std::string const& alias ) const override; 24 | std::string expandAliases( std::string const& unexpandedTestSpec ) const override; 25 | void add( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ); 26 | 27 | private: 28 | std::map m_registry; 29 | }; 30 | 31 | } // end namespace Catch 32 | 33 | #endif // CATCH_TAG_ALIAS_REGISTRY_HPP_INCLUDED 34 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_test_case_info_hasher.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_TEST_CASE_INFO_HASHER_HPP_INCLUDED 9 | #define CATCH_TEST_CASE_INFO_HASHER_HPP_INCLUDED 10 | 11 | #include 12 | 13 | namespace Catch { 14 | 15 | struct TestCaseInfo; 16 | 17 | class TestCaseInfoHasher { 18 | public: 19 | using hash_t = std::uint64_t; 20 | TestCaseInfoHasher( hash_t seed ); 21 | uint32_t operator()( TestCaseInfo const& t ) const; 22 | 23 | private: 24 | hash_t m_seed; 25 | }; 26 | 27 | } // namespace Catch 28 | 29 | #endif /* CATCH_TEST_CASE_INFO_HASHER_HPP_INCLUDED */ 30 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_test_failure_exception.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_TEST_FAILURE_EXCEPTION_HPP_INCLUDED 9 | #define CATCH_TEST_FAILURE_EXCEPTION_HPP_INCLUDED 10 | 11 | namespace Catch { 12 | 13 | //! Used to signal that an assertion macro failed 14 | struct TestFailureException{}; 15 | 16 | } // namespace Catch 17 | 18 | #endif // CATCH_TEST_FAILURE_EXCEPTION_HPP_INCLUDED 19 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_to_string.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_TO_STRING_HPP_INCLUDED 9 | #define CATCH_TO_STRING_HPP_INCLUDED 10 | 11 | #include 12 | 13 | #include 14 | #include 15 | 16 | namespace Catch { 17 | template 18 | std::string to_string(T const& t) { 19 | #if defined(CATCH_CONFIG_CPP11_TO_STRING) 20 | return std::to_string(t); 21 | #else 22 | ReusableStringStream rss; 23 | rss << t; 24 | return rss.str(); 25 | #endif 26 | } 27 | } // end namespace Catch 28 | 29 | #endif // CATCH_TO_STRING_HPP_INCLUDED 30 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_uncaught_exceptions.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | 16 | namespace Catch { 17 | bool uncaught_exceptions() { 18 | #if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) 19 | return false; 20 | #elif defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) 21 | return std::uncaught_exceptions() > 0; 22 | #else 23 | return std::uncaught_exception(); 24 | #endif 25 | } 26 | } // end namespace Catch 27 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_uncaught_exceptions.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED 9 | #define CATCH_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED 10 | 11 | namespace Catch { 12 | bool uncaught_exceptions(); 13 | } // end namespace Catch 14 | 15 | #endif // CATCH_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED 16 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_unique_name.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_UNIQUE_NAME_HPP_INCLUDED 9 | #define CATCH_UNIQUE_NAME_HPP_INCLUDED 10 | 11 | #include 12 | #define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line 13 | #define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) 14 | #ifdef CATCH_CONFIG_COUNTER 15 | # define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ ) 16 | #else 17 | # define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ ) 18 | #endif 19 | 20 | #endif // CATCH_UNIQUE_NAME_HPP_INCLUDED 21 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_void_type.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_VOID_TYPE_HPP_INCLUDED 9 | #define CATCH_VOID_TYPE_HPP_INCLUDED 10 | 11 | 12 | namespace Catch { 13 | namespace Detail { 14 | 15 | template 16 | struct make_void { using type = void; }; 17 | 18 | template 19 | using void_t = typename make_void::type; 20 | 21 | } // namespace Detail 22 | } // namespace Catch 23 | 24 | 25 | #endif // CATCH_VOID_TYPE_HPP_INCLUDED 26 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_wildcard_pattern.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_WILDCARD_PATTERN_HPP_INCLUDED 9 | #define CATCH_WILDCARD_PATTERN_HPP_INCLUDED 10 | 11 | #include 12 | 13 | #include 14 | 15 | namespace Catch 16 | { 17 | class WildcardPattern { 18 | enum WildcardPosition { 19 | NoWildcard = 0, 20 | WildcardAtStart = 1, 21 | WildcardAtEnd = 2, 22 | WildcardAtBothEnds = WildcardAtStart | WildcardAtEnd 23 | }; 24 | 25 | public: 26 | 27 | WildcardPattern( std::string const& pattern, CaseSensitive caseSensitivity ); 28 | bool matches( std::string const& str ) const; 29 | 30 | private: 31 | std::string normaliseString( std::string const& str ) const; 32 | CaseSensitive m_caseSensitivity; 33 | WildcardPosition m_wildcard = NoWildcard; 34 | std::string m_pattern; 35 | }; 36 | } 37 | 38 | #endif // CATCH_WILDCARD_PATTERN_HPP_INCLUDED 39 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/internal/catch_windows_h_proxy.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_WINDOWS_H_PROXY_HPP_INCLUDED 9 | #define CATCH_WINDOWS_H_PROXY_HPP_INCLUDED 10 | 11 | #include 12 | 13 | #if defined(CATCH_PLATFORM_WINDOWS) 14 | 15 | // We might end up with the define made globally through the compiler, 16 | // and we don't want to trigger warnings for this 17 | #if !defined(NOMINMAX) 18 | # define NOMINMAX 19 | #endif 20 | #if !defined(WIN32_LEAN_AND_MEAN) 21 | # define WIN32_LEAN_AND_MEAN 22 | #endif 23 | 24 | #ifdef __AFXDLL 25 | #include 26 | #else 27 | #include 28 | #endif 29 | 30 | #endif // defined(CATCH_PLATFORM_WINDOWS) 31 | 32 | #endif // CATCH_WINDOWS_H_PROXY_HPP_INCLUDED 33 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/matchers/catch_matchers.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | 10 | #include 11 | 12 | namespace Catch { 13 | namespace Matchers { 14 | 15 | std::string MatcherUntypedBase::toString() const { 16 | if (m_cachedToString.empty()) { 17 | m_cachedToString = describe(); 18 | } 19 | return m_cachedToString; 20 | } 21 | 22 | MatcherUntypedBase::~MatcherUntypedBase() = default; 23 | 24 | } // namespace Matchers 25 | } // namespace Catch 26 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/matchers/catch_matchers_container_properties.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | #include 11 | 12 | namespace Catch { 13 | namespace Matchers { 14 | 15 | std::string IsEmptyMatcher::describe() const { 16 | return "is empty"; 17 | } 18 | 19 | std::string HasSizeMatcher::describe() const { 20 | ReusableStringStream sstr; 21 | sstr << "has size == " << m_target_size; 22 | return sstr.str(); 23 | } 24 | 25 | IsEmptyMatcher IsEmpty() { 26 | return {}; 27 | } 28 | 29 | HasSizeMatcher SizeIs(std::size_t sz) { 30 | return HasSizeMatcher{ sz }; 31 | } 32 | 33 | } // end namespace Matchers 34 | } // end namespace Catch 35 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/matchers/catch_matchers_exception.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #include 9 | 10 | namespace Catch { 11 | namespace Matchers { 12 | 13 | bool ExceptionMessageMatcher::match(std::exception const& ex) const { 14 | return ex.what() == m_message; 15 | } 16 | 17 | std::string ExceptionMessageMatcher::describe() const { 18 | return "exception message matches \"" + m_message + '"'; 19 | } 20 | 21 | ExceptionMessageMatcher Message(std::string const& message) { 22 | return ExceptionMessageMatcher(message); 23 | } 24 | 25 | } // namespace Matchers 26 | } // namespace Catch 27 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/matchers/catch_matchers_exception.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_MATCHERS_EXCEPTION_HPP_INCLUDED 9 | #define CATCH_MATCHERS_EXCEPTION_HPP_INCLUDED 10 | 11 | #include 12 | 13 | namespace Catch { 14 | namespace Matchers { 15 | 16 | class ExceptionMessageMatcher final : public MatcherBase { 17 | std::string m_message; 18 | public: 19 | 20 | ExceptionMessageMatcher(std::string const& message): 21 | m_message(message) 22 | {} 23 | 24 | bool match(std::exception const& ex) const override; 25 | 26 | std::string describe() const override; 27 | }; 28 | 29 | //! Creates a matcher that checks whether a std derived exception has the provided message 30 | ExceptionMessageMatcher Message(std::string const& message); 31 | 32 | } // namespace Matchers 33 | } // namespace Catch 34 | 35 | #endif // CATCH_MATCHERS_EXCEPTION_HPP_INCLUDED 36 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/matchers/catch_matchers_predicate.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | std::string Catch::Matchers::Detail::finalizeDescription(const std::string& desc) { 12 | if (desc.empty()) { 13 | return "matches undescribed predicate"; 14 | } else { 15 | return "matches predicate: \"" + desc + '"'; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/matchers/catch_matchers_quantifiers.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #include 9 | 10 | namespace Catch { 11 | namespace Matchers { 12 | std::string AllTrueMatcher::describe() const { return "contains only true"; } 13 | 14 | AllTrueMatcher AllTrue() { return AllTrueMatcher{}; } 15 | 16 | std::string NoneTrueMatcher::describe() const { return "contains no true"; } 17 | 18 | NoneTrueMatcher NoneTrue() { return NoneTrueMatcher{}; } 19 | 20 | std::string AnyTrueMatcher::describe() const { return "contains at least one true"; } 21 | 22 | AnyTrueMatcher AnyTrue() { return AnyTrueMatcher{}; } 23 | } // namespace Matchers 24 | } // namespace Catch 25 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/matchers/internal/catch_matchers_impl.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | namespace Catch { 15 | 16 | // This is the general overload that takes a any string matcher 17 | // There is another overload, in catch_assertionhandler.h/.cpp, that only takes a string and infers 18 | // the Equals matcher (so the header does not mention matchers) 19 | void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher, StringRef matcherString ) { 20 | std::string exceptionMessage = Catch::translateActiveException(); 21 | MatchExpr expr( CATCH_MOVE(exceptionMessage), matcher, matcherString ); 22 | handler.handleExpr( expr ); 23 | } 24 | 25 | } // namespace Catch 26 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/reporters/catch_reporter_automake.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | namespace Catch { 14 | 15 | AutomakeReporter::~AutomakeReporter() {} 16 | 17 | void AutomakeReporter::testCaseEnded(TestCaseStats const& _testCaseStats) { 18 | // Possible values to emit are PASS, XFAIL, SKIP, FAIL, XPASS and ERROR. 19 | m_stream << ":test-result: "; 20 | if (_testCaseStats.totals.assertions.allPassed()) { 21 | m_stream << "PASS"; 22 | } else if (_testCaseStats.totals.assertions.allOk()) { 23 | m_stream << "XFAIL"; 24 | } else { 25 | m_stream << "FAIL"; 26 | } 27 | m_stream << ' ' << _testCaseStats.testInfo->name << '\n'; 28 | StreamingReporterBase::testCaseEnded(_testCaseStats); 29 | } 30 | 31 | void AutomakeReporter::skipTest(TestCaseInfo const& testInfo) { 32 | m_stream << ":test-result: SKIP " << testInfo.name << '\n'; 33 | } 34 | 35 | } // end namespace Catch 36 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/reporters/catch_reporter_compact.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_REPORTER_COMPACT_HPP_INCLUDED 9 | #define CATCH_REPORTER_COMPACT_HPP_INCLUDED 10 | 11 | 12 | #include 13 | 14 | 15 | namespace Catch { 16 | 17 | class CompactReporter final : public StreamingReporterBase { 18 | public: 19 | using StreamingReporterBase::StreamingReporterBase; 20 | 21 | ~CompactReporter() override; 22 | 23 | static std::string getDescription(); 24 | 25 | void noMatchingTestCases( StringRef unmatchedSpec ) override; 26 | 27 | void testRunStarting( TestRunInfo const& _testInfo ) override; 28 | 29 | void assertionEnded(AssertionStats const& _assertionStats) override; 30 | 31 | void sectionEnded(SectionStats const& _sectionStats) override; 32 | 33 | void testRunEnded(TestRunStats const& _testRunStats) override; 34 | 35 | }; 36 | 37 | } // end namespace Catch 38 | 39 | #endif // CATCH_REPORTER_COMPACT_HPP_INCLUDED 40 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/reporters/catch_reporter_registrars.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | #include 12 | 13 | namespace Catch { 14 | namespace Detail { 15 | 16 | void registerReporterImpl( std::string const& name, 17 | IReporterFactoryPtr reporterPtr ) { 18 | CATCH_TRY { 19 | getMutableRegistryHub().registerReporter( 20 | name, CATCH_MOVE( reporterPtr ) ); 21 | } 22 | CATCH_CATCH_ALL { 23 | // Do not throw when constructing global objects, instead 24 | // register the exception to be processed later 25 | getMutableRegistryHub().registerStartupException(); 26 | } 27 | } 28 | 29 | } // namespace Detail 30 | } // namespace Catch 31 | -------------------------------------------------------------------------------- /Lib/Catch2/src/catch2/reporters/catch_reporter_streaming_base.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #include 9 | 10 | namespace Catch { 11 | 12 | StreamingReporterBase::~StreamingReporterBase() = default; 13 | 14 | void 15 | StreamingReporterBase::testRunStarting( TestRunInfo const& _testRunInfo ) { 16 | currentTestRunInfo = _testRunInfo; 17 | } 18 | 19 | void StreamingReporterBase::testRunEnded( TestRunStats const& ) { 20 | currentTestCaseInfo = nullptr; 21 | } 22 | 23 | } // end namespace Catch 24 | -------------------------------------------------------------------------------- /Lib/Catch2/tests/ExtraTests/ToDo.txt: -------------------------------------------------------------------------------- 1 | Configuration options that are left default and thus are not properly tested 2 | yet: 3 | 4 | CATCH_CONFIG_COUNTER // Use __COUNTER__ to generate unique names for test cases 5 | CATCH_CONFIG_WINDOWS_SEH // Enable SEH handling on Windows 6 | CATCH_CONFIG_FAST_COMPILE // Sacrifices some (rather minor) features for compilation speed 7 | CATCH_CONFIG_POSIX_SIGNALS // Enable handling POSIX signals 8 | CATCH_CONFIG_WINDOWS_CRTDBG // Enable leak checking using Windows's CRT Debug Heap 9 | CATCH_CONFIG_DEFAULT_REPORTER 10 | CATCH_CONFIG_ENABLE_ALL_STRINGMAKERS 11 | -------------------------------------------------------------------------------- /Lib/Catch2/tests/ExtraTests/X03-DisabledExceptions-DefaultHandler.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | TEST_CASE("Tests that run") { 15 | // All of these should be run and be reported 16 | CHECK(1 == 2); 17 | CHECK(1 == 1); 18 | CHECK(1 != 3); 19 | CHECK(1 == 4); 20 | } 21 | 22 | 23 | 24 | TEST_CASE("Tests that abort") { 25 | // Avoid abort and other exceptional exits -- there is no way 26 | // to tell CMake that abort is the desired outcome of a test. 27 | std::set_terminate([](){exit(1);}); 28 | REQUIRE(1 == 1); 29 | REQUIRE(1 != 2); 30 | REQUIRE(1 == 3); 31 | // We should not get here, because the test above aborts 32 | REQUIRE(1 != 4); 33 | } 34 | 35 | TEST_CASE( "Misc. macros to check that they compile without exceptions" ) { 36 | BENCHMARK( "simple benchmark" ) { return 1 * 2 + 3; }; 37 | REQUIRE_THAT( 1, 38 | Catch::Matchers::Predicate( []( int i ) { return i == 1; } ) ); 39 | } 40 | -------------------------------------------------------------------------------- /Lib/Catch2/tests/ExtraTests/X04-DisabledExceptions-CustomHandler.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | #include 12 | 13 | namespace Catch { 14 | [[noreturn]] 15 | void throw_exception(std::exception const& e) { 16 | std::cerr << "====== CUSTOM HANDLER ====== run terminates because an exception was thrown.\n" 17 | << "The message was: " << e.what() << '\n'; 18 | // Avoid abort and other exceptional exits -- there is no way 19 | // to tell CMake that abort is the desired outcome of a test. 20 | exit(1); 21 | } 22 | } 23 | 24 | TEST_CASE("Tests that run") { 25 | // All of these should be run and be reported 26 | CHECK(1 == 2); 27 | CHECK(1 == 1); 28 | CHECK(1 != 3); 29 | CHECK(1 == 4); 30 | } 31 | 32 | 33 | 34 | TEST_CASE("Tests that abort") { 35 | REQUIRE(1 == 1); 36 | REQUIRE(1 != 2); 37 | REQUIRE(1 == 3); 38 | // We should not get here, because the test above aborts 39 | REQUIRE(1 != 4); 40 | } 41 | -------------------------------------------------------------------------------- /Lib/Catch2/tests/ExtraTests/X05-DeferredStaticChecks.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | /**\file 10 | * Checks that when `STATIC_CHECK` is deferred to runtime and fails, it 11 | * does not abort the test case. 12 | */ 13 | 14 | #include 15 | 16 | TEST_CASE("Deferred static checks") { 17 | STATIC_CHECK(1 == 2); 18 | STATIC_CHECK_FALSE(1 != 2); 19 | // This last assertion must be executed too 20 | CHECK(1 == 2); 21 | } 22 | -------------------------------------------------------------------------------- /Lib/Catch2/tests/ExtraTests/X10-FallbackStringifier.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | /**\file 10 | * Test that the user can define custom fallbackStringifier 11 | * 12 | * This is done by defining a custom fallback stringifier that prints 13 | * out a specific string, and then asserting (to cause stringification) 14 | * over a type without stringification support. 15 | */ 16 | 17 | #include 18 | 19 | // A catch-all stringifier 20 | template 21 | std::string fallbackStringifier(T const&) { 22 | return "{ !!! }"; 23 | } 24 | 25 | #include 26 | 27 | struct foo { 28 | explicit operator bool() const { 29 | return true; 30 | } 31 | }; 32 | 33 | TEST_CASE("aa") { 34 | REQUIRE(foo{}); 35 | } 36 | -------------------------------------------------------------------------------- /Lib/Catch2/tests/ExtraTests/X11-DisableStringification.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | /**\file 10 | * Test that stringification of original expression can be disabled. 11 | * 12 | * This is a workaround for VS 2017, 2019 issue with Raw String literals 13 | * and preprocessor token pasting. 14 | */ 15 | 16 | 17 | #include 18 | 19 | namespace { 20 | struct Hidden {}; 21 | 22 | bool operator==(Hidden, Hidden) { return true; } 23 | } 24 | 25 | TEST_CASE("DisableStringification") { 26 | REQUIRE( Hidden{} == Hidden{} ); 27 | } 28 | -------------------------------------------------------------------------------- /Lib/Catch2/tests/ExtraTests/X12-CustomDebugBreakMacro.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | /**\file 10 | * Test that user-defined `CATCH_BREAK_INTO_DEBUGGER` is respected and used. 11 | */ 12 | 13 | #include 14 | 15 | void custom_debug_break() { 16 | std::cerr << "Pretty please, break into debugger\n"; 17 | } 18 | 19 | #define CATCH_BREAK_INTO_DEBUGGER() custom_debug_break() 20 | 21 | #define CATCH_CONFIG_MAIN 22 | #include 23 | 24 | TEST_CASE("Failing test that breaks into debugger", "[macros]") { 25 | REQUIRE(1 == 2); 26 | } 27 | -------------------------------------------------------------------------------- /Lib/Catch2/tests/ExtraTests/X23-CasingInReporterNames.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | /**\file 10 | * Test that reporter registration is case-preserving, selection is 11 | * case-insensitive. 12 | * 13 | * This is done by registering a custom reporter that prints out a marker 14 | * string upon construction and then invoking the binary with different 15 | * casings of the name. 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | class TestReporter : public Catch::StreamingReporterBase { 25 | public: 26 | TestReporter(Catch::ReporterConfig&& _config): 27 | StreamingReporterBase(std::move(_config)) { 28 | std::cout << "TestReporter constructed\n"; 29 | } 30 | 31 | static std::string getDescription() { 32 | return "Reporter for testing casing handling in reporter registration/selection"; 33 | } 34 | 35 | ~TestReporter() override; 36 | }; 37 | 38 | TestReporter::~TestReporter() = default; 39 | 40 | CATCH_REGISTER_REPORTER("testReporterCASED", TestReporter) 41 | 42 | -------------------------------------------------------------------------------- /Lib/Catch2/tests/ExtraTests/X30-BazelReporter.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | /**\file 10 | * Test the Bazel report functionality with a simple set 11 | * of dummy test cases. 12 | */ 13 | 14 | #include 15 | 16 | TEST_CASE( "Passing test case" ) { REQUIRE( 1 == 1 ); } 17 | TEST_CASE( "Failing test case" ) { REQUIRE( 2 == 1 ); } 18 | -------------------------------------------------------------------------------- /Lib/Catch2/tests/ExtraTests/X31-DuplicatedTestCases.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | /**\file 10 | * Checks that test cases with identical name and tags are reported as error 11 | */ 12 | 13 | #include 14 | 15 | TEST_CASE("A test case with duplicated name and tags", "[tag1][tag2]") {} 16 | TEST_CASE("A test case with duplicated name and tags", "[tag1][tag2]") {} 17 | -------------------------------------------------------------------------------- /Lib/Catch2/tests/ExtraTests/X32-DuplicatedTestCasesDifferentTags.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | /**\file 10 | * Checks that test cases with identical name but different tags are 11 | * not reported as an error. 12 | */ 13 | 14 | #include 15 | 16 | TEST_CASE("A test case with duplicated name but different tags", "[tag1]") {} 17 | TEST_CASE("A test case with duplicated name but different tags", "[tag2]") {} 18 | -------------------------------------------------------------------------------- /Lib/Catch2/tests/ExtraTests/X33-DuplicatedTestCaseMethods.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | /**\file 10 | * Checks that test case methods with identical class, name and tags are 11 | * reported as error. 12 | */ 13 | 14 | #include 15 | 16 | class TestCaseFixture { 17 | public: 18 | int m_a; 19 | }; 20 | 21 | TEST_CASE_METHOD(TestCaseFixture, "A test case with duplicated name and tags", "[tag1]") {} 22 | TEST_CASE_METHOD(TestCaseFixture, "A test case with duplicated name and tags", "[tag1]") {} 23 | -------------------------------------------------------------------------------- /Lib/Catch2/tests/ExtraTests/X34-DuplicatedTestCaseMethodsDifferentFixtures.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | /**\file 10 | * Checks that test case methods with different class, but same name and 11 | * tags name and tags are not reported as error. 12 | */ 13 | 14 | #include 15 | 16 | class TestCaseFixture1 { 17 | public: 18 | int m_a; 19 | }; 20 | 21 | class TestCaseFixture2 { 22 | public: 23 | int m_a; 24 | }; 25 | 26 | TEST_CASE_METHOD(TestCaseFixture1, "A test case with duplicated name and tags", "[tag1]") {} 27 | TEST_CASE_METHOD(TestCaseFixture2, "A test case with duplicated name and tags", "[tag1]") {} 28 | -------------------------------------------------------------------------------- /Lib/Catch2/tests/ExtraTests/X35-DuplicatedReporterNames.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | /**\file 10 | * Checks that reporter registration errors are caught and handled as 11 | * startup errors, by causing a registration error by registering multiple 12 | * reporters with the same name. 13 | */ 14 | 15 | #include 16 | 17 | #include 18 | #include 19 | 20 | namespace { 21 | //! Trivial custom reporter for registration 22 | class TestReporter : public Catch::StreamingReporterBase { 23 | public: 24 | using StreamingReporterBase::StreamingReporterBase; 25 | 26 | static std::string getDescription() { return "X35 test reporter"; } 27 | }; 28 | } 29 | 30 | CATCH_REGISTER_REPORTER( "test-reporter", TestReporter ) 31 | CATCH_REGISTER_REPORTER( "test-reporter", TestReporter ) 32 | -------------------------------------------------------------------------------- /Lib/Catch2/tests/ExtraTests/X90-WindowsHeaderInclusion.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | /**\file 10 | * Test that the Catch2 header compiles even after including windows.h 11 | * without defining NOMINMAX first. 12 | * 13 | * As an FYI, if you do that, you are wrong. 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | TEST_CASE("Catch2 did survive compilation with windows.h", "[compile-test]") { 20 | SUCCEED(); 21 | } 22 | -------------------------------------------------------------------------------- /Lib/Catch2/tests/ExtraTests/X91-AmalgamatedCatch.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | /**\file 10 | * This file serves as a simple compilation test against the amalgamated 11 | * version of Catch2. 12 | */ 13 | 14 | #include "catch_amalgamated.hpp" 15 | 16 | TEST_CASE("Just a dummy test") { 17 | auto i = GENERATE(1, 2, 3); 18 | SECTION("a") { 19 | REQUIRE(1 != 4); 20 | } 21 | SECTION("b") { 22 | CHECK(1 != 5); 23 | } 24 | REQUIRE_THAT(1, 25 | Catch::Matchers::Predicate([](int i) { 26 | return i % 2 == 1; 27 | })); 28 | } 29 | 30 | TEMPLATE_TEST_CASE("Trivial template test case", "", char, short) { 31 | STATIC_REQUIRE(sizeof(TestType) <= sizeof(int)); 32 | } 33 | 34 | TEST_CASE("Benchmark test", "[!benchmark]") { 35 | BENCHMARK("Allocation benchmark") { 36 | return std::vector(10); 37 | }; 38 | } 39 | -------------------------------------------------------------------------------- /Lib/Catch2/tests/ExtraTests/X92-NoTests.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | /**\file 10 | * Links into executable with no tests which should fail when run 11 | */ 12 | -------------------------------------------------------------------------------- /Lib/Catch2/tests/SelfTest/Baselines/default.sw.multi.approved.txt: -------------------------------------------------------------------------------- 1 | This would not be caught previously 2 | Nor would this 3 | A string sent directly to stdout 4 | A string sent directly to stderr 5 | A string sent to stderr via clog 6 | Message from section one 7 | Message from section two 8 | loose text artifact 9 | -------------------------------------------------------------------------------- /Lib/Catch2/tests/SelfTest/IntrospectiveTests/Stream.tests.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | #include 12 | 13 | TEST_CASE( "Cout stream properly declares it writes to stdout", "[streams]" ) { 14 | REQUIRE( Catch::makeStream( "-" )->isConsole() ); 15 | } 16 | 17 | TEST_CASE( "Empty stream name opens cout stream", "[streams]" ) { 18 | REQUIRE( Catch::makeStream( "" )->isConsole() ); 19 | } 20 | 21 | TEST_CASE( "stdout and stderr streams have %-starting name", "[streams]" ) { 22 | REQUIRE( Catch::makeStream( "%stderr" )->isConsole() ); 23 | REQUIRE( Catch::makeStream( "%stdout" )->isConsole() ); 24 | } 25 | 26 | TEST_CASE( "request an unknown %-starting stream fails", "[streams]" ) { 27 | REQUIRE_THROWS( Catch::makeStream( "%somestream" ) ); 28 | } 29 | 30 | TEST_CASE( "makeStream recognizes %debug stream name", "[streams]" ) { 31 | REQUIRE_NOTHROW( Catch::makeStream( "%debug" ) ); 32 | } 33 | -------------------------------------------------------------------------------- /Lib/Catch2/tests/SelfTest/Misc/invalid-test-names.input: -------------------------------------------------------------------------------- 1 | Test with special, characters in \" name 2 | -------------------------------------------------------------------------------- /Lib/Catch2/tests/SelfTest/Misc/plain-old-tests.input: -------------------------------------------------------------------------------- 1 | random SECTION tests 2 | nested SECTION tests 3 | -------------------------------------------------------------------------------- /Lib/Catch2/tests/SelfTest/Misc/special-characters-in-file.input: -------------------------------------------------------------------------------- 1 | Test with special\, characters \"in name 2 | -------------------------------------------------------------------------------- /Lib/Catch2/tests/SelfTest/TimingTests/Sleep.tests.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | TEST_CASE( "sleep_for_100ms", "[.min_duration_test][approvals]" ) 15 | { 16 | std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) ); 17 | CHECK( true ); 18 | } 19 | 20 | TEST_CASE( "sleep_for_1000ms", "[.min_duration_test][approvals]" ) 21 | { 22 | std::this_thread::sleep_for( std::chrono::milliseconds( 1'000 ) ); 23 | CHECK( true ); 24 | } 25 | -------------------------------------------------------------------------------- /Lib/Catch2/tests/SelfTest/UsageTests/Decomposition.tests.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | #include 11 | 12 | namespace { 13 | 14 | struct truthy { 15 | truthy(bool b):m_value(b){} 16 | operator bool() const { 17 | return false; 18 | } 19 | bool m_value; 20 | }; 21 | 22 | std::ostream& operator<<(std::ostream& o, truthy) { 23 | o << "Hey, its truthy!"; 24 | return o; 25 | } 26 | 27 | } // end anonymous namespace 28 | 29 | #include 30 | 31 | TEST_CASE( "Reconstruction should be based on stringification: #914" , "[Decomposition][failing][.]") { 32 | CHECK(truthy(false)); 33 | } 34 | 35 | TEST_CASE("#1005: Comparing pointer to int and long (NULL can be either on various systems)", "[Decomposition][approvals]") { 36 | FILE* fptr = nullptr; 37 | REQUIRE(fptr == 0); 38 | REQUIRE(fptr == 0l); 39 | } 40 | -------------------------------------------------------------------------------- /Lib/Catch2/tests/SelfTest/UsageTests/ToStringByte.tests.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | #if defined(CATCH_CONFIG_CPP17_BYTE) 12 | 13 | TEST_CASE( "std::byte -> toString", "[toString][byte][approvals]" ) { 14 | using type = std::byte; 15 | REQUIRE( "0" == ::Catch::Detail::stringify( type{ 0 } ) ); 16 | } 17 | 18 | TEST_CASE( "std::vector -> toString", "[toString][byte][approvals]" ) { 19 | using type = std::vector; 20 | REQUIRE( "{ 0, 1, 2 }" == ::Catch::Detail::stringify( type{ std::byte{0}, std::byte{1}, std::byte{2} } ) ); 21 | } 22 | 23 | #endif // CATCH_INTERNAL_CONFIG_CPP17_BYTE 24 | -------------------------------------------------------------------------------- /Lib/Catch2/tests/SelfTest/UsageTests/ToStringOptional.tests.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #define CATCH_CONFIG_ENABLE_OPTIONAL_STRINGMAKER 10 | #include 11 | 12 | #if defined(CATCH_CONFIG_CPP17_OPTIONAL) 13 | 14 | TEST_CASE( "std::optional -> toString", "[toString][optional][approvals]" ) { 15 | using type = std::optional; 16 | REQUIRE( "{ }" == ::Catch::Detail::stringify( type{} ) ); 17 | REQUIRE( "0" == ::Catch::Detail::stringify( type{ 0 } ) ); 18 | } 19 | 20 | TEST_CASE( "std::optional -> toString", "[toString][optional][approvals]" ) { 21 | using type = std::optional; 22 | REQUIRE( "{ }" == ::Catch::Detail::stringify( type{} ) ); 23 | REQUIRE( "\"abc\"" == ::Catch::Detail::stringify( type{ "abc" } ) ); 24 | } 25 | 26 | TEST_CASE( "std::vector > -> toString", "[toString][optional][approvals]" ) { 27 | using type = std::vector >; 28 | REQUIRE( "{ 0, { }, 2 }" == ::Catch::Detail::stringify( type{ 0, {}, 2 } ) ); 29 | } 30 | 31 | #endif // CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL 32 | -------------------------------------------------------------------------------- /Lib/Catch2/tests/SelfTest/UsageTests/VariadicMacros.tests.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | 12 | TEST_CASE() 13 | { 14 | SUCCEED( "anonymous test case" ); 15 | } 16 | 17 | TEST_CASE( "Test case with one argument" ) 18 | { 19 | SUCCEED( "no assertions" ); 20 | } 21 | 22 | TEST_CASE( "Variadic macros", "[variadic][sections]" ) 23 | { 24 | SECTION( "Section with one argument" ) 25 | { 26 | SUCCEED( "no assertions" ); 27 | } 28 | } 29 | 30 | -------------------------------------------------------------------------------- /Lib/Catch2/tools/misc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | project(CatchCoverageHelper) 4 | 5 | add_executable(CoverageHelper coverage-helper.cpp) 6 | set_property(TARGET CoverageHelper PROPERTY CXX_STANDARD 11) 7 | set_property(TARGET CoverageHelper PROPERTY CXX_STANDARD_REQUIRED ON) 8 | set_property(TARGET CoverageHelper PROPERTY CXX_EXTENSIONS OFF) 9 | if (MSVC) 10 | target_compile_options( CoverageHelper PRIVATE /W4 /w44265 /WX /w44061 /w44062 ) 11 | endif() 12 | -------------------------------------------------------------------------------- /Lib/Catch2/tools/misc/appveyorBuildConfigurationScript.bat: -------------------------------------------------------------------------------- 1 | SETLOCAL EnableDelayedExpansion 2 | 3 | @REM # Possibilities: 4 | @REM # Debug build + coverage 5 | @REM # Debug build + examples 6 | @REM # Debug build + --- 7 | @REM # Release build 8 | if "%CONFIGURATION%"=="Debug" ( 9 | if "%coverage%"=="1" ( 10 | @REM # coverage needs to build the special helper as well as the main 11 | cmake -Htools/misc -Bbuild-misc -A%PLATFORM% || exit /b !ERRORLEVEL! 12 | cmake --build build-misc || exit /b !ERRORLEVEL! 13 | cmake -H. -BBuild -A%PLATFORM% -DCATCH_TEST_USE_WMAIN=%wmain% -DMEMORYCHECK_COMMAND=build-misc\Debug\CoverageHelper.exe -DMEMORYCHECK_COMMAND_OPTIONS=--sep-- -DMEMORYCHECK_TYPE=Valgrind -DCATCH_BUILD_EXAMPLES=%examples% -DCATCH_BUILD_EXTRA_TESTS=%examples% -DCATCH_ENABLE_CONFIGURE_TESTS=%configure_tests% -DCATCH_DEVELOPMENT_BUILD=ON || exit /b !ERRORLEVEL! 14 | ) else ( 15 | @REM # We know that coverage is 0 16 | cmake -H. -BBuild -A%PLATFORM% -DCATCH_TEST_USE_WMAIN=%wmain% -DCATCH_BUILD_EXAMPLES=%examples% -DCATCH_BUILD_EXTRA_TESTS=%examples% -DCATCH_BUILD_SURROGATES=%surrogates% -DCATCH_DEVELOPMENT_BUILD=ON -DCATCH_ENABLE_CONFIGURE_TESTS=%configure_tests% || exit /b !ERRORLEVEL! 17 | ) 18 | ) 19 | if "%CONFIGURATION%"=="Release" ( 20 | cmake -H. -BBuild -A%PLATFORM% -DCATCH_TEST_USE_WMAIN=%wmain% -DCATCH_DEVELOPMENT_BUILD=ON || exit /b !ERRORLEVEL! 21 | ) 22 | -------------------------------------------------------------------------------- /Lib/Catch2/tools/misc/appveyorMergeCoverageScript.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | import glob 4 | import subprocess 5 | 6 | if __name__ == '__main__': 7 | cov_files = list(glob.glob('tests/cov-report*.bin')) 8 | base_cmd = ['OpenCppCoverage', '--quiet', '--export_type=cobertura:cobertura.xml'] + ['--input_coverage={}'.format(f) for f in cov_files] 9 | subprocess.check_call(base_cmd) 10 | -------------------------------------------------------------------------------- /Lib/Catch2/tools/misc/appveyorTestRunScript.bat: -------------------------------------------------------------------------------- 1 | SETLOCAL EnableDelayedExpansion 2 | 3 | rem Disable launching the JIT debugger for ctest.exe 4 | reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug\AutoExclusionList" /v "ctest.ext" /t REG_DWORD /d 1 5 | cd Build 6 | if "%CONFIGURATION%"=="Debug" ( 7 | if "%coverage%"=="1" ( 8 | ctest -j 2 -C %CONFIGURATION% -D ExperimentalMemCheck || exit /b !ERRORLEVEL! 9 | python ..\tools\misc\appveyorMergeCoverageScript.py || exit /b !ERRORLEVEL! 10 | codecov --root .. --no-color --disable gcov -f cobertura.xml -t %CODECOV_TOKEN% || exit /b !ERRORLEVEL! 11 | ) else ( 12 | ctest -j 2 -C %CONFIGURATION% || exit /b !ERRORLEVEL! 13 | ) 14 | ) 15 | if "%CONFIGURATION%"=="Release" ( 16 | ctest -j 2 -C %CONFIGURATION% || exit /b !ERRORLEVEL! 17 | ) 18 | -------------------------------------------------------------------------------- /Lib/Catch2/tools/misc/installOpenCppCoverage.ps1: -------------------------------------------------------------------------------- 1 | # Downloads are done from the official github release page links 2 | $downloadUrl = "https://github.com/OpenCppCoverage/OpenCppCoverage/releases/download/release-0.9.9.0/OpenCppCoverageSetup-x64-0.9.9.0.exe" 3 | $installerPath = [System.IO.Path]::Combine($Env:USERPROFILE, "Downloads", "OpenCppCoverageSetup.exe") 4 | 5 | if(-Not (Test-Path $installerPath)) { 6 | Write-Host -ForegroundColor White ("Downloading OpenCppCoverage from: " + $downloadUrl) 7 | Start-FileDownload $downloadUrl -FileName $installerPath 8 | } 9 | 10 | Write-Host -ForegroundColor White "About to install OpenCppCoverage..." 11 | 12 | $installProcess = (Start-Process $installerPath -ArgumentList '/VERYSILENT' -PassThru -Wait) 13 | if($installProcess.ExitCode -ne 0) { 14 | throw [System.String]::Format("Failed to install OpenCppCoverage, ExitCode: {0}.", $installProcess.ExitCode) 15 | } 16 | 17 | # Assume standard, boring, installation path of ".../Program Files/OpenCppCoverage" 18 | $installPath = [System.IO.Path]::Combine(${Env:ProgramFiles}, "OpenCppCoverage") 19 | $env:Path="$env:Path;$installPath" 20 | -------------------------------------------------------------------------------- /Lib/Catch2/tools/scripts/approve.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from __future__ import print_function 4 | 5 | import os 6 | import sys 7 | import shutil 8 | import glob 9 | from scriptCommon import catchPath 10 | 11 | rootPath = os.path.join( catchPath, 'tests/SelfTest/Baselines' ) 12 | 13 | if len(sys.argv) > 1: 14 | files = [os.path.join( rootPath, f ) for f in sys.argv[1:]] 15 | else: 16 | files = glob.glob( os.path.join( rootPath, "*.unapproved.txt" ) ) 17 | 18 | 19 | def approveFile( approvedFile, unapprovedFile ): 20 | justFilename = unapprovedFile[len(rootPath)+1:] 21 | if os.path.exists( unapprovedFile ): 22 | if os.path.exists( approvedFile ): 23 | os.remove( approvedFile ) 24 | os.rename( unapprovedFile, approvedFile ) 25 | print( "approved " + justFilename ) 26 | else: 27 | print( "approval file " + justFilename + " does not exist" ) 28 | 29 | if files: 30 | for unapprovedFile in files: 31 | approveFile( unapprovedFile.replace( "unapproved.txt", "approved.txt" ), unapprovedFile ) 32 | else: 33 | print( "no files to approve" ) 34 | -------------------------------------------------------------------------------- /Lib/Catch2/tools/scripts/buildAndTest.cmd: -------------------------------------------------------------------------------- 1 | rem Start at the root of the Catch project directory, for example: 2 | rem cd Catch2 3 | 4 | rem begin-snippet: catch2-build-and-test-win 5 | rem 1. Regenerate the amalgamated distribution 6 | python tools\scripts\generateAmalgamatedFiles.py 7 | 8 | rem 2. Configure the full test build 9 | cmake -Bdebug-build -H. -DCMAKE_BUILD_TYPE=Debug -DCATCH_DEVELOPMENT_BUILD=ON -DCATCH_BUILD_EXAMPLES=ON -DCATCH_BUILD_EXTRA_TESTS=ON -DCATCH_ENABLE_CONFIGURE_TESTS=ON 10 | 11 | rem 3. Run the actual build 12 | cmake --build debug-build 13 | 14 | rem 4. Run the tests using CTest 15 | cd debug-build 16 | ctest -j 4 --output-on-failure -C Debug 17 | rem end-snippet 18 | -------------------------------------------------------------------------------- /Lib/Catch2/tools/scripts/buildAndTest.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # Start at the root of the Catch project directory, for example: 4 | # cd Catch2 5 | 6 | # begin-snippet: catch2-build-and-test 7 | # 1. Regenerate the amalgamated distribution 8 | ./tools/scripts/generateAmalgamatedFiles.py 9 | 10 | # 2. Configure the full test build 11 | cmake -Bdebug-build -H. -DCMAKE_BUILD_TYPE=Debug -DCATCH_DEVELOPMENT_BUILD=ON -DCATCH_BUILD_EXAMPLES=ON -DCATCH_BUILD_EXTRA_TESTS=ON -DCATCH_ENABLE_CONFIGURE_TESTS=ON 12 | 13 | # 3. Run the actual build 14 | cmake --build debug-build 15 | 16 | # 4. Run the tests using CTest 17 | cd debug-build 18 | ctest -j 4 --output-on-failure -C Debug 19 | # end-snippet 20 | -------------------------------------------------------------------------------- /Lib/Catch2/tools/scripts/checkDuplicateFilenames.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import os 4 | import sys 5 | 6 | files_set = set() 7 | 8 | for root, dir, files in os.walk("src/catch2"): 9 | for file in files: 10 | if file not in files_set: 11 | files_set.add(file) 12 | else: 13 | print("File %s is duplicate" % file) 14 | sys.exit(1) 15 | -------------------------------------------------------------------------------- /Lib/Catch2/tools/scripts/checkLicense.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import sys 4 | import glob 5 | 6 | correct_licence = """\ 7 | 8 | // Copyright Catch2 Authors 9 | // Distributed under the Boost Software License, Version 1.0. 10 | // (See accompanying file LICENSE_1_0.txt or copy at 11 | // https://www.boost.org/LICENSE_1_0.txt) 12 | 13 | // SPDX-License-Identifier: BSL-1.0 14 | """ 15 | 16 | def check_licence_in_file(filename: str) -> bool: 17 | with open(filename, 'r') as f: 18 | file_preamble = ''.join(f.readlines()[:7]) 19 | 20 | if correct_licence != file_preamble: 21 | print('File {} does not have proper licence'.format(filename)) 22 | return False 23 | return True 24 | 25 | def check_licences_in_path(path: str) -> int: 26 | failed = 0 27 | files_to_check = glob.glob(path + '/**/*.cpp', recursive=True) \ 28 | + glob.glob(path + '/**/*.hpp', recursive=True) 29 | for file in files_to_check: 30 | if not check_licence_in_file(file): 31 | failed += 1 32 | return failed 33 | 34 | def check_licences(): 35 | failed = 0 36 | roots = ['src/catch2', 'tests'] 37 | for root in roots: 38 | failed += check_licences_in_path(root) 39 | 40 | if failed: 41 | print('{} files are missing licence'.format(failed)) 42 | sys.exit(1) 43 | 44 | if __name__ == "__main__": 45 | check_licences() 46 | -------------------------------------------------------------------------------- /Lib/Catch2/tools/scripts/developBuild.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from __future__ import print_function 4 | import releaseCommon 5 | 6 | v = releaseCommon.Version() 7 | v.incrementBuildNumber() 8 | releaseCommon.performUpdates(v) 9 | 10 | print( "Updated Version.hpp, README and Conan to v{0}".format( v.getVersionString() ) ) 11 | -------------------------------------------------------------------------------- /Lib/Catch2/tools/scripts/majorRelease.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from __future__ import print_function 4 | import releaseCommon 5 | 6 | v = releaseCommon.Version() 7 | v.incrementMajorVersion() 8 | releaseCommon.performUpdates(v) 9 | 10 | print( "Updated Version.hpp, README and Conan to v{0}".format( v.getVersionString() ) ) 11 | -------------------------------------------------------------------------------- /Lib/Catch2/tools/scripts/minorRelease.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from __future__ import print_function 4 | import releaseCommon 5 | 6 | v = releaseCommon.Version() 7 | v.incrementMinorVersion() 8 | releaseCommon.performUpdates(v) 9 | 10 | print( "Updated Version.hpp, README and Conan to v{0}".format( v.getVersionString() ) ) 11 | -------------------------------------------------------------------------------- /Lib/Catch2/tools/scripts/patchRelease.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from __future__ import print_function 4 | import releaseCommon 5 | 6 | v = releaseCommon.Version() 7 | v.incrementPatchNumber() 8 | releaseCommon.performUpdates(v) 9 | 10 | print( "Updated Version.hpp, README and Conan to v{0}".format( v.getVersionString() ) ) 11 | -------------------------------------------------------------------------------- /Lib/Catch2/tools/scripts/scriptCommon.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import subprocess 4 | 5 | 6 | catchPath = os.path.dirname(os.path.dirname(os.path.realpath( os.path.dirname(sys.argv[0])))) 7 | 8 | def getBuildExecutable(): 9 | if os.name == 'nt': 10 | dir = os.environ.get('CATCH_DEV_OUT_DIR', "cmake-build-debug/projects/SelfTest.exe") 11 | return dir 12 | else: 13 | dir = os.environ.get('CATCH_DEV_OUT_DIR', "cmake-build-debug/projects/SelfTest") 14 | return dir 15 | 16 | 17 | def runAndCapture( args ): 18 | child = subprocess.Popen(" ".join( args ), shell=True, stdout=subprocess.PIPE) 19 | lines = [] 20 | line = "" 21 | while True: 22 | out = child.stdout.read(1) 23 | if out == '' and child.poll(): 24 | break 25 | if out != '': 26 | if out == '\n': 27 | lines.append( line ) 28 | line = "" 29 | else: 30 | line = line + out 31 | return lines 32 | -------------------------------------------------------------------------------- /Lib/Catch2/tools/scripts/updateDocumentSnippets.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from scriptCommon import catchPath 4 | import os 5 | import subprocess 6 | 7 | # --------------------------------------------------- 8 | # Update code examples 9 | # --------------------------------------------------- 10 | # For info on mdsnippets, see https://github.com/SimonCropp/MarkdownSnippets 11 | 12 | # install dotnet SDK from http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409 13 | # Then install MarkdownSnippets.Tool with 14 | # dotnet tool install -g MarkdownSnippets.Tool 15 | # To update: 16 | # dotnet tool update -g MarkdownSnippets.Tool 17 | # To uninstall (e.g. to downgrade to a lower version) 18 | # dotnet tool uninstall -g MarkdownSnippets.Tool 19 | 20 | os.chdir(catchPath) 21 | 22 | subprocess.run('dotnet tool update -g MarkdownSnippets.Tool --version 21.2.0', shell=True, check=True) 23 | subprocess.run('mdsnippets', shell=True, check=True) 24 | -------------------------------------------------------------------------------- /aflat.cfg: -------------------------------------------------------------------------------- 1 | ; Aflat Config File 2 | e main 3 | t test/test 4 | o ./bin/apac 5 | set debug 6 | -------------------------------------------------------------------------------- /coverage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | BUILD_DIR="build" 4 | REPORT_DIR="coverage" 5 | 6 | rm -rf "$BUILD_DIR" "$REPORT_DIR" coverage.info 7 | cmake -S . -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="--coverage" -DCMAKE_C_FLAGS="--coverage" 8 | cmake --build "$BUILD_DIR" --target test -j $(nproc) 9 | ./bin/test "$@" 10 | 11 | lcov --capture --directory "$BUILD_DIR" --output-file coverage.info 12 | lcov --remove coverage.info '/usr/*' -o coverage.info 13 | mkdir -p "$REPORT_DIR" 14 | genhtml coverage.info --output-directory "$REPORT_DIR" > /dev/null 15 | 16 | echo "Coverage report generated in $REPORT_DIR/index.html" 17 | -------------------------------------------------------------------------------- /format-all.sh: -------------------------------------------------------------------------------- 1 | STYLE='Google' 2 | 3 | function format { 4 | clang-format $1 -style $STYLE -i 5 | } 6 | 7 | format ./include/Parser/* 8 | format ./include/CodeGenerator/* 9 | format ./include/* 10 | 11 | format ./src/* 12 | format ./src/Parser/* 13 | format ./src/CodeGenerator/* -------------------------------------------------------------------------------- /include/CodeGenerator/Expr.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include "ASM.hpp" 5 | 6 | namespace gen { 7 | class Expr { 8 | public: 9 | asmc::OpType op = asmc::Hard; 10 | std::string access; 11 | std::string type = ""; 12 | asmc::Size size; 13 | bool passable = true; 14 | Expr() = default; 15 | }; 16 | } // namespace gen 17 | -------------------------------------------------------------------------------- /include/CodeGenerator/GenerationResult.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include "CodeGenerator/Expr.hpp" 5 | 6 | namespace gen { 7 | struct GenerationResult { 8 | asmc::File file; 9 | std::optional expr; 10 | }; 11 | } // namespace gen 12 | -------------------------------------------------------------------------------- /include/CodeGenerator/MockCodeGenerator.hpp: -------------------------------------------------------------------------------- 1 | #include "CodeGenerator/CodeGenerator.hpp" 2 | 3 | namespace test { 4 | namespace mockGen { 5 | class CodeGenerator : public gen::CodeGenerator { 6 | parse::Parser &parser; 7 | 8 | public: 9 | CodeGenerator(std::string moduleId, parse::Parser &parser, 10 | const std::string &source = ""); 11 | 12 | bool canAssign(ast::Type type, std::string typeName, std::string fmt, 13 | bool strict = false); 14 | bool addType(gen::Type *type); 15 | }; 16 | } // namespace mockGen 17 | } // namespace test -------------------------------------------------------------------------------- /include/CompilerUtils.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace compilerutils { 5 | 6 | std::string buildCompileCmd(const std::string &srcPath, 7 | const std::string &destPath, 8 | bool debug); 9 | 10 | std::string buildLinkCmd(const std::string &output, 11 | const std::string &linkerList, 12 | bool debug); 13 | 14 | } // namespace compilerutils 15 | -------------------------------------------------------------------------------- /include/Configs.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace cfg { 6 | 7 | enum Mutability { Promiscuous = 0, Strict = 1, Safe = 2 }; 8 | 9 | struct Config { 10 | std::string aflatVersion; 11 | std::vector modules; 12 | std::vector cFiles; 13 | std::string testFile; 14 | std::string entryPoint; 15 | std::string outPutFile = "./bin/a.out"; 16 | Mutability mutability = Mutability::Strict; 17 | bool debug = false; 18 | bool compatibility = false; 19 | bool asm_ = false; 20 | }; 21 | 22 | Config getConfig(std::string content); 23 | 24 | } // namespace cfg -------------------------------------------------------------------------------- /include/Exceptions.hpp: -------------------------------------------------------------------------------- 1 | #if !defined(ERR) 2 | #define ERR 3 | 4 | #include 5 | 6 | namespace err { 7 | class Exception { 8 | public: 9 | std::string errorMsg; 10 | explicit Exception(std::string msg); 11 | }; 12 | } // namespace err 13 | 14 | #endif // ERR -------------------------------------------------------------------------------- /include/Parser/AST/Statements.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Statements.hpp 3 | * @brief This file will be used to bulk include all of the ast::Statment 4 | * classes 5 | */ 6 | 7 | #pragma once 8 | #include "Parser/AST/Statements/Assign.hpp" 9 | #include "Parser/AST/Statements/Break.hpp" 10 | #include "Parser/AST/Statements/Call.hpp" 11 | #include "Parser/AST/Statements/Class.hpp" 12 | #include "Parser/AST/Statements/Continue.hpp" 13 | #include "Parser/AST/Statements/Dec.hpp" 14 | #include "Parser/AST/Statements/DecArr.hpp" 15 | #include "Parser/AST/Statements/DecAssign.hpp" 16 | #include "Parser/AST/Statements/DecAssignArr.hpp" 17 | #include "Parser/AST/Statements/Declare.hpp" 18 | #include "Parser/AST/Statements/Delete.hpp" 19 | #include "Parser/AST/Statements/Destructure.hpp" 20 | #include "Parser/AST/Statements/Enum.hpp" 21 | #include "Parser/AST/Statements/For.hpp" 22 | #include "Parser/AST/Statements/ForEach.hpp" 23 | #include "Parser/AST/Statements/Function.hpp" 24 | #include "Parser/AST/Statements/If.hpp" 25 | #include "Parser/AST/Statements/Import.hpp" 26 | #include "Parser/AST/Statements/Inc.hpp" 27 | #include "Parser/AST/Statements/Return.hpp" 28 | #include "Parser/AST/Statements/Sequence.hpp" 29 | #include "Parser/AST/Statements/Struct.hpp" 30 | #include "Parser/AST/Statements/Transform.hpp" 31 | #include "Parser/AST/Statements/While.hpp" -------------------------------------------------------------------------------- /include/Parser/AST/Statements/Assign.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Parser/AST.hpp" 3 | 4 | namespace ast { 5 | /** 6 | * @class Assign 7 | * @brief This class is used to represent an assignment statement 8 | */ 9 | class Assign : public Statement { 10 | public: 11 | std::string Ident; 12 | bool reference = false; 13 | bool override = false; 14 | Expr *expr; 15 | links::LinkedList modList; 16 | links::LinkedList indices; 17 | bool to = false; 18 | gen::GenerationResult const generate(gen::CodeGenerator &generator) override; 19 | Assign() = default; 20 | Assign(const std::string &ident, const links::LinkedList &indices, 21 | links::LinkedList modList, 22 | links::LinkedList &tokens, parse::Parser &parser); 23 | }; 24 | } // namespace ast -------------------------------------------------------------------------------- /include/Parser/AST/Statements/Break.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Parser/AST.hpp" 3 | 4 | namespace ast { 5 | /** 6 | * @class Break 7 | * @brief This class is used to represent a continue statement 8 | */ 9 | class Break : public Statement { 10 | public: 11 | int level = 1; 12 | Break() = default; 13 | explicit Break(int level) : level(level){}; 14 | // copy constructor 15 | Break(const Break &other) : level(other.level){}; 16 | Break(links::LinkedList &tokens); 17 | gen::GenerationResult const generate(gen::CodeGenerator &generator); 18 | }; 19 | } // namespace ast -------------------------------------------------------------------------------- /include/Parser/AST/Statements/Call.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Parser/AST.hpp" 3 | 4 | namespace ast { 5 | /** 6 | * @class Call 7 | * @brief This class is used to represent a function call statement 8 | */ 9 | class Call : public Statement { 10 | public: 11 | std::string ident; 12 | links::LinkedList Args; 13 | links::LinkedList modList; 14 | std::string publify = ""; 15 | gen::GenerationResult const generate(gen::CodeGenerator &generator) override; 16 | Call() = default; 17 | Call(const std::string &ident, const links::LinkedList &args, 18 | links::LinkedList modList) 19 | : ident(ident), Args(args), modList(modList) {} 20 | std::string toString() override; 21 | }; 22 | 23 | } // namespace ast -------------------------------------------------------------------------------- /include/Parser/AST/Statements/Class.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Parser/AST.hpp" 3 | 4 | namespace ast { 5 | /* 6 | * @class Class 7 | * @brief This class will represent a class 8 | */ 9 | class Class : public Statement { 10 | public: 11 | Ident ident; 12 | std::string base; 13 | std::vector annotations; 14 | Statement *contract; 15 | Statement *statement; 16 | bool safeType = false; 17 | bool dynamic = false; 18 | bool pedantic = false; 19 | bool includer = false; 20 | Class() = default; 21 | Class(links::LinkedList &tokens, parse::Parser &parser, 22 | bool safeType, bool dynamic, bool pedantic, 23 | std::vector &annotations); 24 | gen::GenerationResult const generate(gen::CodeGenerator &generator) override; 25 | }; 26 | }; // namespace ast -------------------------------------------------------------------------------- /include/Parser/AST/Statements/Continue.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Parser/AST.hpp" 3 | 4 | namespace ast { 5 | /** 6 | * @class Continue 7 | * @brief This class is used to represent a continue statement 8 | */ 9 | class Continue : public Statement { 10 | public: 11 | int level = 1; 12 | Continue() = default; 13 | explicit Continue(int level) : level(level){}; 14 | // copy constructor 15 | Continue(const Continue &other) : level(other.level){}; 16 | Continue(links::LinkedList &tokens); 17 | gen::GenerationResult const generate(gen::CodeGenerator &generator); 18 | }; 19 | } // namespace ast -------------------------------------------------------------------------------- /include/Parser/AST/Statements/Dec.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Parser/AST.hpp" 3 | 4 | namespace ast { 5 | /** 6 | * @class Dec 7 | * @brief This class is used to represent an increment statement 8 | */ 9 | class Dec : public Statement { 10 | public: 11 | std::string ident; 12 | Dec() = default; 13 | Dec(const std::string &ident, links::LinkedList &tokens); 14 | gen::GenerationResult const generate(gen::CodeGenerator &generator); 15 | }; 16 | 17 | } // namespace ast -------------------------------------------------------------------------------- /include/Parser/AST/Statements/DecArr.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Parser/AST.hpp" 3 | 4 | namespace ast { 5 | /** 6 | * @class DecArr 7 | * @brief Represents a declaration of an array. 8 | */ 9 | class DecArr : public Statement { 10 | public: 11 | std::string ident; 12 | Type type; 13 | int count; 14 | bool mut = true; 15 | ScopeMod scope; 16 | links::LinkedList indices; 17 | DecArr() = default; 18 | gen::GenerationResult const generate(gen::CodeGenerator &generator) override; 19 | }; 20 | 21 | } // namespace ast -------------------------------------------------------------------------------- /include/Parser/AST/Statements/DecAssign.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Parser/AST.hpp" 3 | 4 | namespace ast { 5 | /** 6 | * @class DecAssign 7 | * @brief Represents a declaration and assignment statement. 8 | */ 9 | class DecAssign : public Statement { 10 | public: 11 | std::vector annotations; 12 | 13 | Declare *declare; 14 | bool mute = true; 15 | Expr *expr; 16 | gen::GenerationResult const generate(gen::CodeGenerator &generator) override; 17 | DecAssign() = default; 18 | DecAssign(Declare *declare, const bool mute, 19 | links::LinkedList &tokens, parse::Parser &parser, 20 | const std::vector &annotations); 21 | 22 | DecAssign(const DecAssign &other) 23 | : declare(other.declare), mute(other.mute), expr(other.expr) { 24 | this->logicalLine = other.logicalLine; 25 | } 26 | void debug(); 27 | }; 28 | } // namespace ast -------------------------------------------------------------------------------- /include/Parser/AST/Statements/DecAssignArr.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Parser/AST.hpp" 3 | 4 | namespace ast { 5 | /** 6 | * @class DecAssign 7 | * @brief Represents a declaration and assignment statement. 8 | */ 9 | class DecAssignArr : public Statement { 10 | public: 11 | DecArr *declare; 12 | bool mute = true; 13 | Expr *expr; 14 | gen::GenerationResult const generate(gen::CodeGenerator &generator) override; 15 | }; 16 | } // namespace ast -------------------------------------------------------------------------------- /include/Parser/AST/Statements/Declare.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Parser/AST.hpp" 3 | 4 | namespace ast { 5 | /** 6 | * @class Declare 7 | * @brief Represents a declaration statement. 8 | */ 9 | class Declare : public Arg, public Statement { 10 | public: 11 | ScopeMod scope; 12 | std::string ident; 13 | std::string TypeName; 14 | std::string requestType; 15 | links::LinkedList modList; 16 | bool mask = false; 17 | bool mut = true; 18 | bool trust = false; 19 | Type type; 20 | Declare() = default; 21 | Declare(const std::string &ident, const ScopeMod &scope, 22 | const std::string &TypeName, const bool mut, const Type &type, 23 | const std::string &requestType, 24 | links::LinkedList modList) 25 | : ident(ident), 26 | scope(scope), 27 | TypeName(TypeName), 28 | mut(mut), 29 | type(type), 30 | requestType(requestType), 31 | modList(modList) {} 32 | Declare(const Declare &other) 33 | : ident(other.ident), 34 | scope(other.scope), 35 | TypeName(other.TypeName), 36 | mut(other.mut), 37 | type(other.type), 38 | requestType(other.requestType), 39 | modList(other.modList) { 40 | this->logicalLine = other.logicalLine; 41 | } 42 | gen::GenerationResult const generate(gen::CodeGenerator &generator) override; 43 | }; 44 | }; // namespace ast -------------------------------------------------------------------------------- /include/Parser/AST/Statements/Delete.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Parser/AST.hpp" 3 | 4 | namespace ast { 5 | /** 6 | * @class Delete 7 | * @brief This class is used to represent a delete statement 8 | */ 9 | class Delete : public Statement { 10 | public: 11 | std::string ident; 12 | links::LinkedList modList; 13 | Delete() = default; 14 | Delete(links::LinkedList &tokens, parse::Parser &parser); 15 | gen::GenerationResult const generate(gen::CodeGenerator &generator); 16 | }; 17 | } // namespace ast -------------------------------------------------------------------------------- /include/Parser/AST/Statements/Destructure.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Parser/AST.hpp" 3 | 4 | namespace ast { 5 | /** 6 | * @class Destructure 7 | * @brief Node for destructuring assignment 8 | * let {a, b} = Identifier; or let {a, b} = {1, 2}; 9 | */ 10 | class Destructure : public Statement { 11 | public: 12 | std::vector identifiers; 13 | ast::Expr *expr; 14 | bool mute; 15 | Destructure() = default; 16 | Destructure(const bool mute, links::LinkedList &tokens, 17 | parse::Parser &parser); 18 | gen::GenerationResult const generate(gen::CodeGenerator &generator) override; 19 | }; 20 | }; // namespace ast -------------------------------------------------------------------------------- /include/Parser/AST/Statements/Enum.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Parser/Parser.hpp" 3 | #include "Scanner.hpp" 4 | 5 | namespace ast { 6 | /** 7 | * @class Enum 8 | * @brief This class will represent an enum 9 | */ 10 | class Enum : public Statement { 11 | public: 12 | std::string Ident; 13 | std::vector values; 14 | Enum() = default; 15 | Enum(links::LinkedList &tokens, parse::Parser &parser); 16 | gen::GenerationResult const generate(gen::CodeGenerator &generator) override; 17 | }; 18 | } // namespace ast 19 | -------------------------------------------------------------------------------- /include/Parser/AST/Statements/For.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Parser/AST.hpp" 3 | #include "Parser/Parser.hpp" 4 | #include "Scanner.hpp" 5 | 6 | namespace ast { 7 | /* 8 | * @class For 9 | * @brief this class will represent a for loop 10 | */ 11 | class For : public Statement { 12 | public: 13 | Statement *declare; 14 | Expr *expr; 15 | Statement *increment; 16 | Statement *Run; 17 | For() = default; 18 | For(links::LinkedList &tokens, parse::Parser &parser); 19 | gen::GenerationResult const generate(gen::CodeGenerator &generator) override; 20 | }; 21 | 22 | } // namespace ast 23 | -------------------------------------------------------------------------------- /include/Parser/AST/Statements/ForEach.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Parser/AST.hpp" 3 | #include "Parser/Parser.hpp" 4 | #include "Scanner.hpp" 5 | 6 | namespace ast { 7 | /* 8 | * @class ForEach 9 | * @brief this class will represent a for each loop 10 | */ 11 | class ForEach : public Statement { 12 | public: 13 | Lambda *lambda; 14 | Expr *iterator; 15 | ForEach() = default; 16 | ForEach(links::LinkedList &tokens, parse::Parser &parser); 17 | gen::GenerationResult const generate(gen::CodeGenerator &generator) override; 18 | }; 19 | } // namespace ast -------------------------------------------------------------------------------- /include/Parser/AST/Statements/If.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "LinkedList.hpp" 3 | #include "Parser/AST.hpp" 4 | #include "Parser/Parser.hpp" 5 | #include "Scanner.hpp" 6 | 7 | namespace ast { 8 | /* 9 | * @class If 10 | * @brief This class will be used to represent an if statement 11 | */ 12 | class If : public Statement { 13 | public: 14 | Expr *expr; 15 | Statement *statement; 16 | Statement *elseStatement; 17 | Statement *elseIf; 18 | If() = default; 19 | If(links::LinkedList &tokens, parse::Parser &parser); 20 | gen::GenerationResult const generate(gen::CodeGenerator &generator) override; 21 | }; 22 | } // namespace ast -------------------------------------------------------------------------------- /include/Parser/AST/Statements/Import.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Parser/AST.hpp" 3 | 4 | namespace ast { 5 | /* 6 | * @class Import 7 | * @brief This class is used to represent an import statement 8 | */ 9 | class Import : public Statement { 10 | public: 11 | std::vector imports; 12 | std::string path; 13 | std::string nameSpace; 14 | bool classes = false; 15 | Import() = default; 16 | Import(links::LinkedList &tokens, parse::Parser &parser); 17 | gen::GenerationResult const generate(gen::CodeGenerator &generator); 18 | }; 19 | }; // namespace ast -------------------------------------------------------------------------------- /include/Parser/AST/Statements/Inc.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Parser/AST.hpp" 3 | 4 | namespace ast { 5 | /** 6 | * @class Inc 7 | * @brief This class is used to represent an increment statement 8 | */ 9 | class Inc : public Statement { 10 | public: 11 | std::string ident; 12 | Inc() = default; 13 | Inc(const std::string &ident, links::LinkedList &tokens); 14 | gen::GenerationResult const generate(gen::CodeGenerator &generator) override; 15 | }; 16 | 17 | } // namespace ast -------------------------------------------------------------------------------- /include/Parser/AST/Statements/Return.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Parser/AST.hpp" 3 | #include "Parser/AST/Statements/Return.hpp" 4 | 5 | namespace ast { 6 | class Expr; 7 | class Return : public Statement { 8 | public: 9 | Expr *expr; 10 | bool empty = false; 11 | 12 | gen::GenerationResult const generate(gen::CodeGenerator &generateor) override; 13 | Return() = default; 14 | Return(links::LinkedList &tokens, parse::Parser &parser); 15 | }; 16 | }; // namespace ast 17 | -------------------------------------------------------------------------------- /include/Parser/AST/Statements/Sequence.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Parser/AST.hpp" 3 | 4 | namespace ast { 5 | /** 6 | * @class Sequence 7 | * @brief This class is used to represent a sequence of statements 8 | */ 9 | class Sequence : public Statement { 10 | public: 11 | Statement *Statement1; 12 | Statement *Statement2; 13 | gen::GenerationResult const generate(gen::CodeGenerator &generator) override; 14 | Sequence() = default; 15 | }; 16 | 17 | }; // namespace ast -------------------------------------------------------------------------------- /include/Parser/AST/Statements/Struct.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Parser/AST.hpp" 3 | 4 | namespace ast { 5 | /* 6 | * @class Struct 7 | * @brief This class will represent a struct 8 | */ 9 | class Struct : public Member, public Statement { 10 | public: 11 | Ident ident; 12 | Statement *statement; 13 | Struct() = default; 14 | Struct(links::LinkedList &tokens, parse::Parser &parser); 15 | gen::GenerationResult const generate(gen::CodeGenerator &generator) override; 16 | }; 17 | } // namespace ast 18 | -------------------------------------------------------------------------------- /include/Parser/AST/Statements/Transform.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include "Parser/AST.hpp" 5 | 6 | namespace ast { 7 | class Transform : public Statement { 8 | public: 9 | std::string ident; 10 | std::string _template; 11 | 12 | Transform(links::LinkedList &tokens); 13 | Transform(const std::string &ident, const std::string &templateStr) 14 | : ident(ident), _template(templateStr) {} 15 | Transform() = default; 16 | ~Transform() = default; 17 | gen::GenerationResult const generate(gen::CodeGenerator &generator) override; 18 | ast::Statement *parse(const std::string &ident, std::string &type, 19 | std::string &exp, std::string &scope, std::string &mut, 20 | std::unordered_map &args, 21 | gen::CodeGenerator &generator); 22 | }; 23 | }; // namespace ast -------------------------------------------------------------------------------- /include/Parser/AST/Statements/While.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Parser/AST.hpp" 3 | 4 | namespace ast { 5 | /* 6 | * @class While 7 | * @brief This class will be used to represent a while statement 8 | */ 9 | class While : public Statement { 10 | public: 11 | Expr *expr; 12 | Statement *stmt; 13 | gen::GenerationResult const generate(gen::CodeGenerator &generator) override; 14 | While() = default; 15 | While(links::LinkedList &tokens, parse::Parser &parser); 16 | }; 17 | } // namespace ast 18 | -------------------------------------------------------------------------------- /include/Parser/Lower.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Parser/AST.hpp" 4 | #include "Parser/AST/Statements.hpp" 5 | 6 | namespace parse { 7 | namespace lower { 8 | class Lowerer { 9 | public: 10 | Lowerer(ast::Statement *root, bool snippet); 11 | Lowerer(ast::Statement *root); 12 | 13 | private: 14 | ast::Statement *root; 15 | ast::Statement *curr; 16 | bool inclass = false; 17 | bool snippet = false; 18 | std::string className = ""; 19 | 20 | ast::Statement *lower(ast::Statement *stmt); 21 | ast::Statement *lowerFunction(ast::Function *func); 22 | ast::Function *findFunction(ast::Statement *stmt, std::string ident, 23 | bool &fromClass); 24 | ast::Class *findClass(ast::Statement *stmt, std::string ident); 25 | }; 26 | } // namespace lower 27 | } // namespace parse 28 | -------------------------------------------------------------------------------- /include/PreProcessor.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PrePro 2 | #define PrePro 3 | 4 | #include 5 | #include 6 | 7 | #include "LinkedListS.hpp" 8 | 9 | /*A class to PreProcess The input Code*/ 10 | 11 | /* A class to store a Definition */ 12 | class Definition { 13 | public: 14 | std::string name; 15 | std::string value; 16 | 17 | // Compair a definition and a string 18 | static bool compair(Definition def, std::string str); 19 | }; 20 | 21 | class PreProcessor { 22 | public: 23 | PreProcessor(); 24 | ~PreProcessor(); 25 | std::string PreProcess(std::string code, std::string exePath); 26 | bool debug = false; 27 | 28 | private: 29 | std::string root; 30 | links::SLinkedList definitions; 31 | std::vector includes; 32 | 33 | /* incluse an external file */ 34 | std::string Include(std::string line, std::string exePath); 35 | 36 | /*Define a value*/ 37 | void Define(std::string line); 38 | 39 | /*Replaced defined value with value*/ 40 | void ReplaceDefined(std::string &code); 41 | }; 42 | 43 | #endif -------------------------------------------------------------------------------- /include/Scanner.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LEX 2 | #define LEX 3 | 4 | #include 5 | 6 | #include "LinkedList.hpp" 7 | 8 | using links::LinkedList; 9 | using std::string; 10 | 11 | namespace lex { 12 | 13 | class Token { 14 | public: 15 | int lineCount; 16 | virtual ~Token() = default; 17 | }; 18 | 19 | class Symbol : public Token { 20 | public: 21 | string meta; 22 | }; 23 | 24 | class LObj : public Token { 25 | public: 26 | string meta; 27 | }; 28 | 29 | class Ref : public Token {}; 30 | 31 | class StringObj : public Token { 32 | public: 33 | string value; 34 | }; 35 | 36 | class FStringObj : public Token { 37 | public: 38 | string value; 39 | }; 40 | 41 | class CharObj : public Token { 42 | public: 43 | char value; 44 | }; 45 | 46 | class OpSym : public Token { 47 | public: 48 | char Sym; 49 | }; 50 | 51 | class INT : public Token { 52 | public: 53 | string value; 54 | }; 55 | 56 | class Long : public Token { 57 | public: 58 | string value; 59 | }; 60 | 61 | class FloatLit : public Token { 62 | public: 63 | string value; 64 | }; 65 | 66 | /*This will take apart the string and breake it down into "Words" 67 | that the parser will be able to understand*/ 68 | class Lexer { 69 | public: 70 | LinkedList Scan(string input, int startLine = 1); 71 | }; 72 | 73 | }; // namespace lex 74 | #endif -------------------------------------------------------------------------------- /include/Utils.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include "Parser/AST.hpp" 5 | 6 | namespace utils { 7 | 8 | std::string remove_char(std::string str, char ch); 9 | std::string op_to_string(ast::Op op); 10 | 11 | } // namespace utils -------------------------------------------------------------------------------- /libraries/std/head/asm.gs: -------------------------------------------------------------------------------- 1 | adr brk(adr size); 2 | int sys_write(int file, adr text, int bytes); 3 | int sys_create(adr path, long mode); 4 | int sys_open(adr path, long flags, long mode); 5 | int sys_read(int file, adr to, int count); 6 | int sys_close(int file); 7 | int sys_fstat(int file, adr stat); 8 | int sys_fork(); 9 | int sys_pause(); 10 | int sys_nsleep(adr req, * adr rem); 11 | int sys_time(* adr t); 12 | int sys_times(adr t); 13 | int sys_exit(int err); 14 | int sys_wait(int proc, adr status, int options, adr t); 15 | int sys_pipe(adr fd); 16 | int sys_kill(int pid, int sig); 17 | int sys_socket(int domain, int type, int protocol); 18 | int sys_setsockopt(int s, int level, int optname, adr optval, int optlen); 19 | int sys_bind(int s, adr name, int namelen); 20 | int sys_listen(int s, int backlog); 21 | int sys_accept(int s, adr upeer_sockaddr, adr upeer_addrlen); 22 | int sys_sendto(int s, adr buf, int len, int flags, adr to, int tolen); 23 | int sys_connect(int s, adr name, int namelen); 24 | int sys_execve(adr name, adr argv, adr env); 25 | int sys_clock_gettime(int clk_id, adr tp); -------------------------------------------------------------------------------- /libraries/std/head/request.gs: -------------------------------------------------------------------------------- 1 | bool request(adr host, adr path, adr port, adr msg, adr response, int response_size); 2 | int _aflat_server_spinUp(short port, int requestSize, adr requestHandler, adr args); -------------------------------------------------------------------------------- /libraries/std/head/server.gs: -------------------------------------------------------------------------------- 1 | int serve(int port, adr handler, * adr data); 2 | int serve_sync(int port, adr handler, * adr data); -------------------------------------------------------------------------------- /libraries/std/head/std.gs: -------------------------------------------------------------------------------- 1 | 2 | class Time { 3 | public adr amount; 4 | }; 5 | 6 | class TimeSpec{ 7 | long tv_sec; 8 | long tv_nsec; 9 | }; 10 | 11 | class Times{ 12 | public int tms_utime; 13 | public int tms_stime; 14 | public int tms_cutime; 15 | public int tms_cstime; 16 | }; 17 | 18 | Times newTimes(); 19 | 20 | class Block{ 21 | public int size; 22 | public int free; 23 | public adr next; 24 | }; 25 | 26 | class Bit{ 27 | int value; 28 | adr last; 29 | adr next; 30 | }; 31 | 32 | Bit newBit(int value); 33 | 34 | int free(any ptr); 35 | int blockSize(adr ptr); 36 | Time newTime(adr size); 37 | adr malloc(int size); 38 | adr realloc(adr ptr, int size); 39 | int inspectHeap(); 40 | int memcpy(adr dst,adr src, int size); 41 | int panic(adr msg); 42 | int assert(bool cond, * adr message); 43 | int sleep(int seconds, * int nanoseconds); 44 | adr _fCstr(adr fmt, * adr args); 45 | adr mmap(adr addr, int len, int prot, int flags, int fd, int offset); 46 | adr create(const int size, ? const any value); 47 | void _fEachOr(const adr iterator, const adr callback, *const any args); 48 | adr _toOption(const any value); -------------------------------------------------------------------------------- /libraries/std/head/strings.gs: -------------------------------------------------------------------------------- 1 | export int len(adr str); 2 | export int str_comp(adr str1, adr str2); 3 | export int str_concat(adr str1, adr str2, adr pointer); 4 | export int str_toInt(adr input); 5 | export int str_split(adr str, char sep, adr buff1, adr buff2); 6 | export int str_find(adr in, char find); 7 | export int str_subString(int start, int end, adr str, adr buff); 8 | export int int_toString(int input, adr buffer); 9 | export int int_toStringL0(int input, adr buffer); 10 | export char ascii(int input); 11 | export float charToFloat(char a); 12 | export int str_toFloat(adr input); 13 | export int sPrintFloat(adr input); 14 | export int float_toString(adr input, adr obuff, int signed); 15 | export adr str_reverse(adr in, adr buff); 16 | export char str_at(adr str, int i); 17 | export int str_forEach(adr s, adr foo, adr args); 18 | export bool char_isDigit(char c); -------------------------------------------------------------------------------- /libraries/std/src/Collections/Scroller.af: -------------------------------------------------------------------------------- 1 | .needs 2 | 3 | import Iterator, Next, Peek from "Collections/Iterator"; 4 | import List from "Collections"; 5 | import Result from "Utils/Result"; 6 | import string from "String"; 7 | import { accept, reject } from "Utils/Result" under res; 8 | import EndOfRange from "Collections/Enumerator"; 9 | 10 | class Scroller signs Iterator { 11 | private int index = 0; 12 | private List list = list; 13 | 14 | Result next() : Next { 15 | if my.index < my.list.getCount() { 16 | const int i = my.index; 17 | my.index = my.index + 1; 18 | return res.accept(my.list.get(i).expect("Currupted list")); 19 | }; 20 | return res.reject(new EndOfRange()); 21 | }; 22 | 23 | Result peek() : Peek { 24 | if my.index < my.list.getCount() { 25 | return res.accept(my.list.get(my.index).expect("Currupted list")); 26 | }; 27 | return res.reject(new EndOfRange()); 28 | }; 29 | 30 | Scroller init(const List list) { 31 | return my; 32 | }; 33 | }; -------------------------------------------------------------------------------- /libraries/std/src/HTTP/Middleware.af: -------------------------------------------------------------------------------- 1 | .needs 2 | 3 | import Server from "HTTP/Server"; 4 | import HTTPMessage from "HTTP"; 5 | import string from "String"; 6 | import Map from "Utils/Map"; 7 | 8 | class Middleware { 9 | const Map implementations = implementations(server); 10 | Middleware init(const any implementations, * const Server server) { 11 | if server != NULL 12 | server.addMiddleware(my); 13 | return my; 14 | }; 15 | 16 | string toString() { 17 | return "Middlewear"; 18 | }; 19 | }; -------------------------------------------------------------------------------- /libraries/std/src/JSON/Property.af: -------------------------------------------------------------------------------- 1 | .needs 2 | 3 | import string from "String"; 4 | import {print} from "String" under str; 5 | import JSONType, JSONObject from "JSON"; 6 | import {printHex, print} from "io" under io; 7 | 8 | safe class JSONProperty { 9 | mutable any value; 10 | const string key = key.copy(); 11 | const JSONType type = type; 12 | const adr process = process; 13 | const JSONObject context = context; 14 | 15 | JSONProperty init(const any process, const JSONObject context, const string key, const JSONType type) { 16 | my.context.properties.pushBack(my); 17 | const adr new_me = my.context.properties.back().orElse([] => panic("No properties found when adding int to JSONObject")); 18 | free(my); 19 | return new_me; 20 | }; 21 | 22 | void _set(const any value) { 23 | const let foo = my.process; 24 | my.value = foo(my.context, value); 25 | }; 26 | 27 | any get() { 28 | return my.value; 29 | }; 30 | 31 | adr ref() { 32 | return my; 33 | }; 34 | }; 35 | -------------------------------------------------------------------------------- /libraries/std/src/Memory.af: -------------------------------------------------------------------------------- 1 | .needs 2 | 3 | class RefCounted { 4 | private mutable int refCount = 0; 5 | private mutable bool locked = false; 6 | 7 | fn get() -> Self { 8 | my.refCount = my.refCount + 1; 9 | return my; 10 | }; 11 | 12 | fn endScope() { 13 | if my.locked return; 14 | my.refCount = my.refCount - 1; 15 | if (my.refCount <= 0) { 16 | delete my; 17 | }; 18 | }; 19 | 20 | fn lock() { 21 | my.locked = true; 22 | }; 23 | 24 | fn unlock() { 25 | my.locked = false; 26 | }; 27 | }; 28 | -------------------------------------------------------------------------------- /libraries/std/src/Utils/Defer.af: -------------------------------------------------------------------------------- 1 | .needs 2 | import Function from "Utils/Functions"; 3 | import RefCounted from "Memory"; 4 | 5 | @Apply(RefCounted) 6 | safe dynamic class Defer { 7 | private const Function _func = func; 8 | private mutable bool dismissed = false; 9 | 10 | Defer init(const Function func) { 11 | return my; 12 | }; 13 | 14 | void dismiss() { 15 | my.dismissed = true; 16 | }; 17 | 18 | int del() { 19 | if !my.dismissed 20 | my._func(); 21 | }; 22 | }; -------------------------------------------------------------------------------- /libraries/std/src/Utils/Error/Render.af: -------------------------------------------------------------------------------- 1 | .needs 2 | import string from "String"; 3 | import Error from "Utils/Error"; 4 | 5 | safe dynamic class Render { 6 | int i = 0; 7 | 8 | Render init(const string<> render, const Error context) { 9 | context.setRender(render); 10 | return my; 11 | }; 12 | }; -------------------------------------------------------------------------------- /libraries/std/src/Utils/Functions.af: -------------------------------------------------------------------------------- 1 | .needs 2 | 3 | class Function { 4 | const private adr foo = foo; 5 | const private adr captures = captures; 6 | 7 | Function init(const adr foo, * const any captures) { 8 | return my; 9 | }; 10 | 11 | public any _call(*const any arg1, *const any arg2, *const any arg3, *const any arg4, *const any arg5) { 12 | const let foo = my.foo; 13 | const let captures = my.captures; 14 | if captures == NULL return foo(arg1, arg2, arg3, arg4, arg5); 15 | return foo(captures, arg1, arg2, arg3, arg4, arg5); 16 | }; 17 | }; -------------------------------------------------------------------------------- /libraries/std/src/Utils/Observable.af: -------------------------------------------------------------------------------- 1 | .needs 2 | import List from "Collections"; 3 | import Scroller from "Collections/Scroller"; 4 | import Function from "Utils/Functions"; 5 | 6 | import {print, printHex} from "io" under io; 7 | 8 | class Observable { 9 | List subscribers = new List(Function); 10 | 11 | fn subscribe(const Function f) -> void { 12 | my.subscribers.pushBack(f); 13 | return; 14 | }; 15 | 16 | private fn notify(const any event) -> void { 17 | foreach const Function f : my.subscribers.scroll() { 18 | f(event); 19 | }; 20 | return; 21 | }; 22 | 23 | }; -------------------------------------------------------------------------------- /libraries/std/src/Web/Content/Bind.af: -------------------------------------------------------------------------------- 1 | .needs 2 | import Content from "Web/Content"; 3 | import string from "String"; 4 | import Computed from "Utils/Properties"; 5 | import {print} from "String" under str; 6 | 7 | safe dynamic class Bind { 8 | private const Content context = context; 9 | private const adr preproces = preprocess; 10 | private mutable string name = name; 11 | private mutable string value = "None"; 12 | 13 | public string key() : Computed { 14 | return my.name.copy(); 15 | }; 16 | 17 | public string val() : Computed { 18 | return my.value.copy(); 19 | }; 20 | 21 | Bind init(const adr preprocess, const Content context, const adr name) { 22 | my.name = new string("{{") + my.name + new string("}}"); 23 | my.context.bindings.pushBack(my); 24 | }; 25 | 26 | adr get() { 27 | return my.value; 28 | }; 29 | 30 | void _set(const any value) { 31 | const adr foo = my.preproces; 32 | my.value = new string(foo(my.context, value)); 33 | }; 34 | }; -------------------------------------------------------------------------------- /makefile: -------------------------------------------------------------------------------- 1 | CXX := g++ 2 | CXX_FLAGS := -std=c++17 -O3 -march=native -flto -fpermissive 3 | 4 | BIN := bin 5 | SRC := src 6 | INCLUDE := include 7 | 8 | LIBRARIES := 9 | EXECUTABLE := aflat 10 | 11 | GDB := gdb 12 | 13 | 14 | all: $(BIN)/$(EXECUTABLE) 15 | 16 | run: all 17 | clear 18 | ./$(BIN)/$(EXECUTABLE) 19 | 20 | $(BIN)/$(EXECUTABLE): $(SRC)/*.cpp $(SRC)/CodeGenerator/*.cpp $(SRC)/Parser/*.cpp $(SRC)/Parser/AST/Statements/*.cpp 21 | $(CXX) $(CXX_FLAGS) -I $(INCLUDE) $^ -o $@ $(LIBRARIES) -pthread; 22 | bash ./rebuild-libs.sh 23 | 24 | 25 | clean: 26 | -rm $(BIN)/* 27 | 28 | libs: 29 | bash ./rebuild-libs.sh 30 | 31 | debug: $(GDB) ./$(BIN)/$(EXECUTABLE) -------------------------------------------------------------------------------- /src/CodeGenerator/MockCodeGenerator.cpp: -------------------------------------------------------------------------------- 1 | #include "CodeGenerator/MockCodeGenerator.hpp" 2 | 3 | namespace test { 4 | namespace mockGen { 5 | bool mockGen::CodeGenerator::canAssign(ast::Type type, std::string typeName, 6 | std::string fmt, bool strict) { 7 | return gen::CodeGenerator::canAssign(type, typeName, fmt, strict); 8 | } 9 | 10 | CodeGenerator::CodeGenerator(std::string moduleId, parse::Parser &parser, 11 | const std::string &source) 12 | : gen::CodeGenerator(moduleId, parser, source), parser(parser) {} 13 | 14 | bool CodeGenerator::addType(gen::Type *type) { 15 | this->typeList.push(type); 16 | return true; 17 | } 18 | } // namespace mockGen 19 | } // namespace test 20 | -------------------------------------------------------------------------------- /src/CompilerUtils.cpp: -------------------------------------------------------------------------------- 1 | #include "CompilerUtils.hpp" 2 | 3 | namespace compilerutils { 4 | 5 | std::string buildCompileCmd(const std::string &srcPath, 6 | const std::string &destPath, 7 | bool debug) { 8 | std::string flags; 9 | if (debug) 10 | flags = "-g -no-pie -z noexecstack -S -lefence "; 11 | else 12 | flags = "-O3 -march=native -S -no-pie -z noexecstack "; 13 | return "gcc " + flags + srcPath + " -o " + destPath; 14 | } 15 | 16 | std::string buildLinkCmd(const std::string &output, 17 | const std::string &linkerList, 18 | bool debug) { 19 | std::string flags; 20 | if (debug) 21 | flags = "-O0 -g -no-pie -z noexecstack -o "; 22 | else 23 | flags = "-O3 -march=native -no-pie -z noexecstack -o "; 24 | return "gcc " + flags + output + " " + linkerList; 25 | } 26 | 27 | } // namespace compilerutils 28 | -------------------------------------------------------------------------------- /src/Exceptions.cpp: -------------------------------------------------------------------------------- 1 | #include "Exceptions.hpp" 2 | 3 | err::Exception::Exception(std::string msg) { this->errorMsg = msg; } -------------------------------------------------------------------------------- /src/Parser/AST.cpp: -------------------------------------------------------------------------------- 1 | #include "Parser/AST.hpp" 2 | 3 | #include 4 | 5 | #include "Parser/Parser.hpp" 6 | 7 | using namespace ast; 8 | 9 | bool Type::compare(ast::Type t, std::string name) { 10 | if (t.typeName == name) return true; 11 | return false; 12 | } 13 | -------------------------------------------------------------------------------- /src/Parser/AST/Statements/Break.cpp: -------------------------------------------------------------------------------- 1 | #include "Parser/AST/Statements/Break.hpp" 2 | 3 | #include "CodeGenerator/CodeGenerator.hpp" 4 | 5 | namespace ast { 6 | /** 7 | * @brief Construct a new Break object 8 | */ 9 | Break::Break(links::LinkedList &tokens) { 10 | this->logicalLine = tokens.peek()->lineCount; 11 | if (dynamic_cast(tokens.peek()) != nullptr) 12 | this->level = std::stoi(dynamic_cast(tokens.pop())->value); 13 | else 14 | this->level = 1; 15 | } 16 | 17 | gen::GenerationResult const Break::generate(gen::CodeGenerator &generator) { 18 | asmc::File OutputFile; 19 | if (generator.breakContext.size() == 0) 20 | generator.alert("Attempted to break outside of a loop"); 21 | if (generator.breakContext.size() < this->level) 22 | generator.alert("Attempted to break deeper than the current loop"); 23 | 24 | int index = this->level - 1; 25 | asmc::Jmp *jmp = new asmc::Jmp(); 26 | jmp->logicalLine = this->logicalLine; 27 | jmp->to = generator.breakContext.get(index); 28 | OutputFile.text << jmp; 29 | return {OutputFile, std::nullopt}; 30 | } 31 | 32 | }; // namespace ast -------------------------------------------------------------------------------- /src/Parser/AST/Statements/Continue.cpp: -------------------------------------------------------------------------------- 1 | #include "Parser/AST/Statements/Continue.hpp" 2 | 3 | #include "CodeGenerator/CodeGenerator.hpp" 4 | 5 | namespace ast { 6 | /** 7 | * @brief Construct a new Continue object 8 | */ 9 | Continue::Continue(links::LinkedList &tokens) { 10 | this->logicalLine = tokens.peek()->lineCount; 11 | if (dynamic_cast(tokens.peek()) != nullptr) 12 | this->level = std::stoi(dynamic_cast(tokens.pop())->value); 13 | else 14 | this->level = 1; 15 | } 16 | 17 | gen::GenerationResult const Continue::generate(gen::CodeGenerator &generator) { 18 | asmc::File OutputFile; 19 | if (generator.continueContext.size() == 0) 20 | generator.alert("Attempted to continue outside of a loop"); 21 | if (generator.continueContext.size() < this->level) 22 | generator.alert("Attempted to continue deeper than the current loop"); 23 | 24 | int index = this->level - 1; 25 | asmc::Jmp *jmp = new asmc::Jmp(); 26 | jmp->logicalLine = this->logicalLine; 27 | jmp->to = generator.continueContext.get(index); 28 | OutputFile.text << jmp; 29 | return {OutputFile, std::nullopt}; 30 | } 31 | }; // namespace ast -------------------------------------------------------------------------------- /src/Parser/AST/Statements/DecAssingArr.cpp: -------------------------------------------------------------------------------- 1 | #include "CodeGenerator/CodeGenerator.hpp" 2 | #include "CodeGenerator/ScopeManager.hpp" 3 | #include "CodeGenerator/Utils.hpp" 4 | #include "Parser/AST/Statements/DecAssignArr.hpp" 5 | 6 | namespace ast { 7 | gen::GenerationResult const DecAssignArr::generate( 8 | gen::CodeGenerator &generator) { 9 | asmc::File file; 10 | ast::DecArr *dec = this->declare; 11 | ast::Type adr; 12 | adr.arraySize = 1; 13 | dec->indices.reset(); 14 | while (dec->indices.pos != nullptr) { 15 | ast::IntLiteral *lit = 16 | dynamic_cast(dec->indices.shift()); 17 | if (lit == nullptr) generator.alert("array index must be an integer"); 18 | adr.indices.push(lit->val); 19 | } 20 | adr.indices.invert(); 21 | adr.opType = asmc::Hard; 22 | adr.size = asmc::QWord; 23 | adr.typeName = "adr"; 24 | adr.typeHint = &dec->type; 25 | 26 | const auto declare = 27 | new ast::Declare(dec->ident, dec->scope, "adr", this->mute, adr, "", 28 | links::LinkedList()); 29 | 30 | auto assign = new ast::DecAssign(); 31 | assign->declare = declare; 32 | assign->expr = this->expr; 33 | assign->mute = this->mute; 34 | assign->declare->scope = dec->scope; 35 | file << assign->generate(generator).file; 36 | return {file, std::nullopt}; 37 | } 38 | } // namespace ast -------------------------------------------------------------------------------- /src/Parser/AST/Statements/Sequence.cpp: -------------------------------------------------------------------------------- 1 | #include "Parser/AST/Statements/Sequence.hpp" 2 | 3 | #include "CodeGenerator/CodeGenerator.hpp" 4 | 5 | namespace ast { 6 | gen::GenerationResult const Sequence::generate(gen::CodeGenerator &generator) { 7 | asmc::File file; 8 | if (Statement1) file << generator.GenSTMT(Statement1); 9 | if (Statement2) file << generator.GenSTMT(Statement2); 10 | return {file, std::nullopt}; 11 | } 12 | } // namespace ast -------------------------------------------------------------------------------- /src/Utils.cpp: -------------------------------------------------------------------------------- 1 | #include "Utils.hpp" 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | std::string utils::remove_char(std::string str, char ch) { 11 | str.erase(std::remove(str.begin(), str.end(), ch), str.end()); 12 | return str; 13 | } 14 | 15 | std::string utils::op_to_string(ast::Op op) { 16 | switch (op) { 17 | case ast::Op::Plus: 18 | return "+"; 19 | case ast::Op::Minus: 20 | return "-"; 21 | case ast::Op::Carrot: 22 | return "^"; 23 | case ast::Op::Mod: 24 | return "%"; 25 | case ast::Op::Mul: 26 | return "*"; 27 | case ast::Op::Div: 28 | return "/"; 29 | case ast::Op::Equ: 30 | return "=="; 31 | case ast::Op::NotEqu: 32 | return "!="; 33 | case ast::Op::Less: 34 | return "<"; 35 | case ast::Op::Great: 36 | return ">"; 37 | case ast::Op::AndBit: 38 | return "&"; 39 | case ast::Op::AndBool: 40 | return "&&"; 41 | case ast::Op::OrBit: 42 | return "|"; 43 | case ast::Op::LessCmp: 44 | return "<="; 45 | case ast::Op::GreatCmp: 46 | return ">="; 47 | case ast::Op::CompEqu: 48 | return "==="; 49 | case ast::Op::Leq: 50 | return "<="; 51 | case ast::Op::Geq: 52 | return ">="; 53 | } 54 | return ""; 55 | } 56 | -------------------------------------------------------------------------------- /src/main.af: -------------------------------------------------------------------------------- 1 | .needs 2 | 3 | import string from "String"; 4 | import {print} from "String" under str; 5 | 6 | fn main() { 7 | str.print("Aflat Bin\n"); 8 | }; 9 | -------------------------------------------------------------------------------- /src/test/test.af: -------------------------------------------------------------------------------- 1 | .needs 2 | import string from "String"; 3 | import {print} from "String" under str; 4 | 5 | fn main() { 6 | str.print("Aflat Bin\n"); 7 | }; -------------------------------------------------------------------------------- /test/test.cpp: -------------------------------------------------------------------------------- 1 | #define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do 2 | // this in one cpp file 3 | #include "catch.hpp" -------------------------------------------------------------------------------- /test/test_CompilerUtils.cpp: -------------------------------------------------------------------------------- 1 | #include "CompilerUtils.hpp" 2 | #include "catch.hpp" 3 | 4 | TEST_CASE("compile command uses optimization when not debugging", "[compilerutils]") { 5 | auto cmd = compilerutils::buildCompileCmd("a.c", "a.s", false); 6 | REQUIRE(cmd.find("-O3") != std::string::npos); 7 | REQUIRE(cmd.find("-march=native") != std::string::npos); 8 | REQUIRE(cmd.find("-g") == std::string::npos); 9 | } 10 | 11 | TEST_CASE("link command uses optimization when not debugging", "[compilerutils]") { 12 | auto cmd = compilerutils::buildLinkCmd("a.out", "foo.s", false); 13 | REQUIRE(cmd.find("-O3") != std::string::npos); 14 | REQUIRE(cmd.find("-march=native") != std::string::npos); 15 | REQUIRE(cmd.find("-g") == std::string::npos); 16 | } 17 | 18 | TEST_CASE("debug flags omit optimizations", "[compilerutils]") { 19 | auto cmd = compilerutils::buildLinkCmd("a.out", "foo.s", true); 20 | REQUIRE(cmd.find("-g") != std::string::npos); 21 | REQUIRE(cmd.find("-O3") == std::string::npos); 22 | } 23 | -------------------------------------------------------------------------------- /test/test_Exceptions.cpp: -------------------------------------------------------------------------------- 1 | #include "Exceptions.hpp" 2 | #include "catch.hpp" 3 | 4 | TEST_CASE("Exception stores message", "[exceptions]") { 5 | err::Exception e("oops"); 6 | REQUIRE(e.errorMsg == "oops"); 7 | } 8 | -------------------------------------------------------------------------------- /test/test_HashMap.cpp: -------------------------------------------------------------------------------- 1 | #include "HashMap.hpp" 2 | #include "catch.hpp" 3 | 4 | TEST_CASE("HashMap insert and retrieve", "[hashmap]") { 5 | HashMap map; 6 | int a = 5; 7 | map.insert("a", &a); 8 | REQUIRE(map.size() == 1); 9 | REQUIRE(map.contains("a")); 10 | REQUIRE(*(map.get("a")) == 5); 11 | map.remove("a"); 12 | REQUIRE(map.size() == 0); 13 | REQUIRE_FALSE(map.contains("a")); 14 | } 15 | -------------------------------------------------------------------------------- /test/test_LinkedList.cpp: -------------------------------------------------------------------------------- 1 | #include "LinkedList.hpp" 2 | #include "catch.hpp" 3 | 4 | TEST_CASE("LinkedList push and pop", "[linkedlist]") { 5 | links::LinkedList list; 6 | list.push(1); 7 | list.push(2); 8 | REQUIRE(list.size() == 2); 9 | REQUIRE(list.peek() == 2); 10 | REQUIRE(list.pop() == 2); 11 | REQUIRE(list.size() == 1); 12 | } 13 | 14 | TEST_CASE("LinkedList invert", "[linkedlist]") { 15 | links::LinkedList list; 16 | list.push(1); 17 | list.push(2); 18 | list.invert(); 19 | REQUIRE(list.peek() == 1); 20 | } 21 | -------------------------------------------------------------------------------- /test/test_More.cpp: -------------------------------------------------------------------------------- 1 | #include "CodeGenerator/MockCodeGenerator.hpp" 2 | #include "CodeGenerator/Utils.hpp" 3 | #include "Parser/Parser.hpp" 4 | #include "PreProcessor.hpp" 5 | #include "catch.hpp" 6 | 7 | TEST_CASE("Definition compares name", "[preprocessor]") { 8 | Definition d; 9 | d.name = "FOO"; 10 | d.value = "BAR"; 11 | REQUIRE(Definition::compair(d, "FOO")); 12 | REQUIRE_FALSE(Definition::compair(d, "BAR")); 13 | } 14 | 15 | TEST_CASE("PreProcessor replaces defined values", "[preprocessor]") { 16 | PreProcessor pp; 17 | std::string output = pp.PreProcess(".def X = Y\nX\n", ""); 18 | REQUIRE(output == "Y\n"); 19 | } 20 | 21 | TEST_CASE("getLibPath forms correct suffix", "[cgutils]") { 22 | using gen::utils::getLibPath; 23 | std::string path = getLibPath("foo"); 24 | REQUIRE(path.size() >= 9); 25 | REQUIRE(path.rfind("/libraries/std/foo/", path.size() - 1) != 26 | std::string::npos); 27 | } 28 | 29 | TEST_CASE("getBytes returns expected values", "[codegen]") { 30 | auto parser = parse::Parser(); 31 | gen::CodeGenerator gen("mod", parser); 32 | REQUIRE(gen.getBytes(asmc::QWord) == 8); 33 | REQUIRE(gen.getBytes(asmc::Word) == 2); 34 | REQUIRE(gen.getBytes(asmc::Byte) == 1); 35 | REQUIRE(gen.getBytes(asmc::DWord) == 4); 36 | } 37 | -------------------------------------------------------------------------------- /test/test_PreProcessor.cpp: -------------------------------------------------------------------------------- 1 | #include "PreProcessor.hpp" 2 | #include "catch.hpp" 3 | 4 | TEST_CASE("PreProcessor define replacement", "[preprocessor]") { 5 | PreProcessor pp; 6 | std::string input = ".def X = Y\nX\n"; 7 | REQUIRE(pp.PreProcess(input, "") == "Y\n"); 8 | } 9 | -------------------------------------------------------------------------------- /test/test_SLinkedList.cpp: -------------------------------------------------------------------------------- 1 | #include "LinkedListS.hpp" 2 | #include "catch.hpp" 3 | 4 | static bool comp(int a, int b) { return a == b; } 5 | 6 | TEST_CASE("SLinkedList basic operations", "[slinkedlist]") { 7 | links::SLinkedList list; 8 | list.foo = comp; 9 | list.push(1); 10 | list.push(2); 11 | REQUIRE(list.peek() == 2); 12 | REQUIRE(list.pop() == 2); 13 | REQUIRE(list.count == 1); 14 | REQUIRE(*(list[1]) == 1); 15 | } 16 | -------------------------------------------------------------------------------- /test/test_Scanner.cpp: -------------------------------------------------------------------------------- 1 | #include "Scanner.hpp" 2 | #include "catch.hpp" 3 | 4 | TEST_CASE("Lexer scans identifiers and ints", "[scanner]") { 5 | lex::Lexer l; 6 | auto tokens = l.Scan("foo 123"); 7 | REQUIRE(tokens.size() >= 3); // includes trailing semicolon token 8 | auto *first = dynamic_cast(tokens.get(2)); 9 | auto *second = dynamic_cast(tokens.get(1)); 10 | REQUIRE(first != nullptr); 11 | REQUIRE(first->meta == "foo"); 12 | REQUIRE(second != nullptr); 13 | REQUIRE(second->value == "123"); 14 | } 15 | -------------------------------------------------------------------------------- /test/test_ScopeManager.cpp: -------------------------------------------------------------------------------- 1 | #include "CodeGenerator/ScopeManager.hpp" 2 | #include "Parser/AST.hpp" 3 | #include "catch.hpp" 4 | 5 | TEST_CASE("ScopeManager assign and get", "[scopemanager]") { 6 | auto sm = gen::scope::ScopeManager::getInstance(); 7 | sm->reset(); 8 | ast::Type t; 9 | t.size = asmc::DWord; 10 | t.arraySize = 1; 11 | int offset = sm->assign("x", t, false); 12 | REQUIRE(offset == 4); 13 | auto sym = sm->get("x"); 14 | REQUIRE(sym != nullptr); 15 | REQUIRE(sym->symbol == "x"); 16 | REQUIRE(sm->getStackAlignment() == 16); 17 | } 18 | --------------------------------------------------------------------------------