Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 34 additions & 8 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,27 @@
## Copyright : TTS Contributors & Maintainers
## SPDX-License-Identifier: BSL-1.0
##==================================================================================================
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignConsecutiveAssignments:
Enabled: true
AcrossEmptyLines: true
AcrossComments: true
AlignCompound: true
AlignFunctionPointers: false
PadOperators: true
AlignConsecutiveDeclarations:
Enabled: true
AcrossEmptyLines: true
AcrossComments: true
AlignCompound: true
AlignFunctionPointers: false
PadOperators: true
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
AlignAfterOpenBracket: Align
AllowShortBlocksOnASingleLine: true
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: true
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
AllowShortLoopsOnASingleLine: true
AlwaysBreakTemplateDeclarations: MultiLine
BreakBeforeBraces: Allman
Expand All @@ -24,13 +35,13 @@ Cpp11BracedListStyle: true
FixNamespaceComments: false
IncludeBlocks: Regroup
IndentCaseLabels: false
IndentPPDirectives: AfterHash
IndentPPDirectives: None
IndentWidth: 2
KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
PointerAlignment: Right
SortIncludes: true
PointerAlignment: Left
SortIncludes: Never
SortUsingDeclarations: true
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
Expand All @@ -51,3 +62,18 @@ BinPackArguments: false
BinPackParameters: false
ExperimentalAutoDetectBinPacking: false
AllowAllParametersOfDeclarationOnNextLine: false
QualifierAlignment: Right
ReferenceAlignment: Pointer
AlignArrayOfStructures: Right
AlignConsecutiveMacros:
Enabled: true
AcrossEmptyLines: true
AcrossComments: true
AlignCompound: true
PadOperators: true
AllowShortCaseExpressionOnASingleLine: true
AllowShortEnumsOnASingleLine: true
AllowShortLambdasOnASingleLine: All
BreakBeforeConceptDeclarations: Always
InsertNewlineAtEOF: true
Language: Cpp
2 changes: 1 addition & 1 deletion .github/workflows/package-standalone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ jobs:
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: "standalone"
branch: "standalone"
25 changes: 25 additions & 0 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,29 @@ concurrency:
cancel-in-progress: true

jobs:
##################################################################################################
## Preserve pre-commit checks
##################################################################################################
precommit:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4.1.1
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install pre-commit
run: pip install pre-commit
- name: Run pre-commit checks
run: pre-commit run --all-files --show-diff-on-failure --color=always

##################################################################################################
## Unit Tests
##################################################################################################
windows:
runs-on: [windows-2022]
needs: precommit
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -44,6 +64,7 @@ jobs:

linux:
runs-on: [ubuntu-latest]
needs: precommit
container:
image: ghcr.io/jfalcou/compilers:v9
strategy:
Expand All @@ -70,6 +91,7 @@ jobs:

macosx:
runs-on: [macos-14]
needs: precommit
strategy:
fail-fast: false
matrix:
Expand All @@ -90,6 +112,7 @@ jobs:

android:
runs-on: [macos-14]
needs: precommit
strategy:
fail-fast: false
matrix:
Expand All @@ -108,6 +131,7 @@ jobs:

wasm:
runs-on: ubuntu-latest
needs: precommit
container:
image: ghcr.io/jfalcou/compilers:v9
strategy:
Expand All @@ -131,6 +155,7 @@ jobs:

icpx:
runs-on: ubuntu-latest
needs: precommit
container:
image: ghcr.io/jfalcou/compilers:sycl-v1
strategy:
Expand Down
14 changes: 14 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
exclude: ^doc/.*

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v19.1.7
hooks:
- id: clang-format
types_or: [c++]
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ else()
set(QUIET_OPTION "QUIET")
endif()

##======================================================================================================================
## Precommit hooks setup
##======================================================================================================================
copa_setup_precommit_hooks(${QUIET_OPTION})

##======================================================================================================================
## Install Process setup
##======================================================================================================================
Expand Down
21 changes: 0 additions & 21 deletions format.sh

This file was deleted.

109 changes: 57 additions & 52 deletions include/tts/engine/case.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,80 +22,87 @@ namespace tts::_
{
struct capture
{
capture(const char* id) : name(id) {}
auto operator+(auto body) const { return test::acknowledge( {name, body} ); }
const char* name;
capture(char const* id)
: name(id)
{
}
auto operator+(auto body) const { return test::acknowledge({name, body}); }
char const* name;
};

// Global storage for current type used in a given test
inline text current_type = {};

template<typename... Types> struct captures
{
captures(const char* id) : name(id) {}
captures(char const* id)
: name(id)
{
}

auto operator+(auto body) const
{
// We register all the types in a single test to keep the compile-time O(1)
// Registering different type in different tests generate far too much callable::invoker
// symbol that make compile-time O(N)
return test::acknowledge( { name
, [=]()
{
// We setup the current type name before each test so we know
( ( (current_type = as_text(typename_<Types>))
, (::tts::_::is_verbose && !::tts::_::is_quiet ? printf("> With <T = %s>\n", current_type.data()) : 0)
, body(type<Types>())
)
, ...
);
// Clear the current type
current_type = text{""};
}
}
);
return test::acknowledge({name,
[ = ]()
{
// We setup the current type name before each test so we know
(((current_type = as_text(typename_<Types>)),
(::tts::_::is_verbose && !::tts::_::is_quiet
? printf("> With <T = %s>\n", current_type.data())
: 0),
body(type<Types>())),
...);
// Clear the current type
current_type = text {""};
}});
}
const char* name;
char const* name;
};

// Specialisation for types lists
template<template<typename...> typename List, typename... Types>
requires( !requires(List<Types...>) { typename List<Types...>::types_list; })
requires(!requires(List<Types...>) { typename List<Types...>::types_list; })
struct captures<List<Types...>> : captures<Types...>
{};
{
};

// Specialisation for types list generator
template<typename Generator>
requires requires(Generator) { typename Generator::types_list; }
requires requires(Generator) { typename Generator::types_list; }
struct captures<Generator> : captures<typename Generator::types_list>
{};
{
};

template<typename Types, auto... Generators> struct test_generators;

template<typename... Type,auto... Generators>
template<typename... Type, auto... Generators>
struct test_generators<types<Type...>, Generators...>
{
test_generators(const char* id) : name(id) {}
test_generators(char const* id)
: name(id)
{
}
friend auto operator<<(test_generators tg, auto body)
{
return test::acknowledge( { tg.name
, [body]() mutable
{
(process_type<Type>(body), ...);
current_type = text{""};
}
}
);
return test::acknowledge({tg.name,
[ body ]() mutable
{
(process_type<Type>(body), ...);
current_type = text {""};
}});
}

template<typename T>
static void process_type(auto body)
template<typename T> static void process_type(auto body)
{
current_type = as_text(typename_<T>);
if(::tts::_::is_verbose && !::tts::_::is_quiet) printf("> With <T = %s>\n", current_type.data());
(body(produce(type<T>{},Generators)...));
if(::tts::_::is_verbose && !::tts::_::is_quiet)
printf("> With <T = %s>\n", current_type.data());
(body(produce(type<T> {}, Generators)...));
}
const char* name;
char const* name;
};
}

Expand Down Expand Up @@ -131,9 +138,9 @@ namespace tts::_
#if defined(TTS_DOXYGEN_INVOKED)
#define TTS_CASE(ID)
#else
#define TTS_CASE(ID) \
[[maybe_unused]] static auto const TTS_CAT(case_,TTS_FUNCTION) = ::tts::_::capture{ID} + +[]() \
/**/
#define TTS_CASE(ID) \
[[maybe_unused]] static auto const TTS_CAT(case_, TTS_FUNCTION) = \
::tts::_::capture {ID} + +[]() /**/
#endif

//======================================================================================================================
Expand All @@ -160,11 +167,11 @@ namespace tts::_
**/
//======================================================================================================================
#if defined(TTS_DOXYGEN_INVOKED)
#define TTS_CASE_TPL(ID,...)
#define TTS_CASE_TPL(ID, ...)
#else
#define TTS_CASE_TPL(ID,...) \
[[maybe_unused]] static bool const TTS_CAT(case_,TTS_FUNCTION) = ::tts::_::captures<__VA_ARGS__>{ID} + [] \
/**/
#define TTS_CASE_TPL(ID, ...) \
[[maybe_unused]] static bool const TTS_CAT(case_, TTS_FUNCTION) = \
::tts::_::captures<__VA_ARGS__> {ID} + [] /**/
#endif

//======================================================================================================================
Expand Down Expand Up @@ -193,12 +200,10 @@ namespace tts::_
#if defined(TTS_DOXYGEN_INVOKED)
#define TTS_CASE_WITH(ID, TYPES, ...)
#else
#define TTS_CASE_WITH(ID, TYPES, ...) \
[[maybe_unused]] static bool const TTS_CAT(case_,TTS_FUNCTION) \
= ::tts::_::test_generators< ::tts::as_type_list_t<TTS_REMOVE_PARENS(TYPES)> \
, __VA_ARGS__ \
>{ID} << [] \
/**/
#define TTS_CASE_WITH(ID, TYPES, ...) \
[[maybe_unused]] static bool const TTS_CAT(case_, TTS_FUNCTION) = \
::tts::_::test_generators<::tts::as_type_list_t<TTS_REMOVE_PARENS(TYPES)>, __VA_ARGS__> {ID} \
<< [] /**/
#endif

//======================================================================================================================
Expand Down
Loading