Skip to content

Commit

Permalink
Merge pull request #3212 from eseiler/infra/snippet
Browse files Browse the repository at this point in the history
[FIX] libc++: snippet tests
  • Loading branch information
eseiler authored Nov 17, 2023
2 parents 96518e5 + 73a6ae0 commit 57b9924
Show file tree
Hide file tree
Showing 15 changed files with 117 additions and 102 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/ci_misc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ jobs:
fail-fast: false
matrix:
include:
- name: "Snippet clang17 libc++"
compiler: "clang-17"
build: snippet
build_type: Release
test_threads: 1 # snippets create and delete files and some separate tests create/delete the same files
cxx_flags: "-stdlib=libc++"

- name: "Snippet gcc11"
compiler: "gcc-11"
build: snippet
Expand Down
2 changes: 1 addition & 1 deletion doc/cookbook/simd_dna4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

int main()
{
[[maybe_unused]] simd_dna4 letter{};
simd_dna4 letter{};
}
17 changes: 0 additions & 17 deletions doc/tutorial/04_alphabet/alphabet_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,23 +115,6 @@ int main()
std::set<seqan3::dna4> pyrimidines{'C'_dna4, 'T'_dna4};
//! [containers]

// Prevent -Wunused-variable warnings.
(void)rank_a;
(void)rank_g;
(void)char_a;
(void)char_g;
(void)size1;
(void)size2;
(void)dna_sequence;
(void)alignment_column;
(void)pyrimidines;
(void)eq;
(void)neq;
(void)geq;
(void)gt;
(void)seq;
(void)st;

//! [closing]
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion doc/tutorial/06_minimisers/minimisers_snippets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ int main()
uint64_t const seed = 0x8F3F73B5CF1C9ADE;
auto minimisers = text | seqan3::views::kmer_hash(seqan3::ungapped{4})
| std::views::transform(
[seed](uint64_t i)
[](uint64_t i)
{
return i ^ seed;
})
Expand Down
8 changes: 0 additions & 8 deletions doc/tutorial/08_pairwise_alignment/configurations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ int main()
seqan3::align_cfg::free_end_gaps_sequence1_trailing{false},
seqan3::align_cfg::free_end_gaps_sequence2_trailing{true}};
//! [method_global_free_end_gaps]
(void)config;
}

{
Expand All @@ -57,8 +56,6 @@ int main()
aa_scheme.set_similarity_matrix(seqan3::aminoacid_similarity_matrix::blosum30);
auto sc_aa = aa_scheme.score('M'_aa27, 'K'_aa27); // sc_aa == 2.
//! [scoring_scheme]
(void)sc_nc;
(void)sc_aa;
}

{
Expand All @@ -71,8 +68,6 @@ int main()
int open_score = affine_scheme.open_score; // == -10
int extension_score = affine_scheme.extension_score; // == -1
//! [gap_cost_affine]
(void)open_score;
(void)extension_score;
}

{
Expand All @@ -81,7 +76,6 @@ int main()
// Configure the alignment to only compute the score.
auto cfg = seqan3::align_cfg::output_score{};
//! [output]
(void)cfg;
}

{
Expand All @@ -91,7 +85,6 @@ int main()
auto cfg = seqan3::align_cfg::band_fixed_size{seqan3::align_cfg::lower_diagonal{-4},
seqan3::align_cfg::upper_diagonal{4}};
//! [band]
(void)cfg;
}

{
Expand All @@ -100,6 +93,5 @@ int main()
// Configure an edit distance alignment.
auto cfg = seqan3::align_cfg::method_global{} | seqan3::align_cfg::edit_scheme;
//! [edit]
(void)cfg;
}
}
6 changes: 4 additions & 2 deletions doc/tutorial/11_read_mapper/read_mapper_step2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,21 @@ void map_reads(std::filesystem::path const & query_path,

seqan3::sequence_file_input query_file_in{query_path};

(void)sam_path; // Silence warning about unused parameter. We are not yet using `sam_path`.

seqan3::configuration const search_config =
seqan3::search_cfg::max_error_total{seqan3::search_cfg::error_count{errors}}
| seqan3::search_cfg::hit_all_best{};

for (auto && record : query_file_in | std::views::take(20))
{
(void)storage; // Silence warning about unused parameter. We are not yet using `storage`.

seqan3::debug_stream << "Hits:" << '\n';
for (auto && result : search(record.sequence(), index, search_config))
seqan3::debug_stream << result << '\n';
seqan3::debug_stream << "======================" << '\n';
}
(void)sam_path; // prevent unused parameter warning
(void)storage; // prevent unused parameter warning
}

void run_program(std::filesystem::path const & reference_path,
Expand Down
3 changes: 2 additions & 1 deletion doc/tutorial/11_read_mapper/read_mapper_step3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ void map_reads(std::filesystem::path const & query_path,

seqan3::sequence_file_input query_file_in{query_path};

(void)sam_path; // Silence warning about unused parameter. We are not yet using `sam_path`.

seqan3::configuration const search_config =
seqan3::search_cfg::max_error_total{seqan3::search_cfg::error_count{errors}}
| seqan3::search_cfg::hit_all_best{};
Expand Down Expand Up @@ -79,7 +81,6 @@ void map_reads(std::filesystem::path const & query_path,
}
}
}
(void)sam_path; // prevent unused parameter warning
}
//! [solution]

Expand Down
17 changes: 16 additions & 1 deletion include/seqan3/utility/char_operations/predicate_detail.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <stdexcept>
#include <string>

#include <seqan3/utility/concept.hpp>
#include <seqan3/utility/detail/type_name_as_string.hpp>
#include <seqan3/utility/type_traits/basic.hpp>

Expand Down Expand Up @@ -194,7 +195,21 @@ struct char_predicate_base
constexpr bool operator()(value_t const val) const noexcept
requires (sizeof(value_t) != 1)
{
using char_trait = std::char_traits<value_t>;
// std::char_traits is only guaranteed to be defined for character types.
// libc++ deprecates other specialisations in llvm-17, and removes them in llvm-18.
// We map the non-character types to corresponding chracter types.
// For example, `seqan3::is_eof(EOF)` will call this function with `value_t == int`.
// clang-format off
using char_value_t = std::conditional_t<seqan3::builtin_character<value_t>, value_t,
std::conditional_t<std::same_as<value_t, std::char_traits<char>::int_type>, char,
std::conditional_t<std::same_as<value_t, std::char_traits<wchar_t>::int_type>, wchar_t,
std::conditional_t<std::same_as<value_t, std::char_traits<char8_t>::int_type>, char8_t,
std::conditional_t<std::same_as<value_t, std::char_traits<char16_t>::int_type>, char16_t,
std::conditional_t<std::same_as<value_t, std::char_traits<char32_t>::int_type>, char32_t,
void>>>>>>;
// clang-format on
static_assert(!std::same_as<char_value_t, void>, "There is no valid character representation.");
using char_trait = std::char_traits<char_value_t>;
return (static_cast<std::make_unsigned_t<value_t>>(val) < 256) ? operator()(static_cast<uint8_t>(val))
: (char_trait::eq_int_type(val, char_trait::eof())) ? derived_t::data[256]
: false;
Expand Down
15 changes: 12 additions & 3 deletions include/seqan3/utility/tuple/pod_tuple.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ struct pod_tuple
* actually enforces this on all types in the tuple (if you want to add non POD types, just use
* std::tuple instead).
*
* It (only) supports [aggregate initialization](https://en.cppreference.com/w/cpp/language/aggregate_initialization),
* i.e. you must use brace-initializiers and cannot
* use paranthesis. You can use seqan3::get or std::get and also
* You can use seqan3::get or std::get and also
* [structured bindings](https://en.cppreference.com/w/cpp/language/declarations#Structured_binding_declaration)
* to access the elements in the tuple.
*
Expand All @@ -57,6 +55,17 @@ struct pod_tuple<type0, types...>
type0 _head;
//!\brief The rest of the elements defined as a "recursive member".
pod_tuple<types...> _tail;

constexpr pod_tuple() noexcept = default; //!< Defaulted.
constexpr pod_tuple(pod_tuple const &) noexcept = default; //!< Defaulted.
constexpr pod_tuple & operator=(pod_tuple const &) noexcept = default; //!< Defaulted.
constexpr pod_tuple(pod_tuple &&) noexcept = default; //!< Defaulted.
constexpr pod_tuple & operator=(pod_tuple &&) noexcept = default; //!< Defaulted.
constexpr ~pod_tuple() noexcept = default; //!< Defaulted.

//!\brief Construct from arguments.
constexpr pod_tuple(type0 v0, types... args) noexcept : _head{v0}, _tail{args...}
{}
//!\endcond

/*!\name Comparison operators
Expand Down
3 changes: 2 additions & 1 deletion test/snippet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ option (SEQAN3_GENERATE_SNIPPETS "Whether seqan3 snippets should be generated an

add_library (snippet_main snippet_main.cpp)
target_link_libraries (snippet_main PUBLIC seqan3::test gtest)
target_compile_options (snippet_main PUBLIC "-Wno-unused-variable" "-Wno-unused-but-set-variable")

macro (seqan3_snippet test_name_prefix snippet snippet_base_path)
seqan3_test_component (snippet_target_name "${snippet}" TARGET_NAME)
Expand All @@ -24,7 +25,7 @@ macro (seqan3_snippet test_name_prefix snippet snippet_base_path)
set (target "${snippet_target_name}_snippet")

add_executable (${target} "${snippet_base_path}/${snippet}")
target_link_libraries (${target} PUBLIC snippet_main)
target_link_libraries (${target} PUBLIC seqan3::test snippet_main)
set_target_properties (${target} PROPERTIES RUNTIME_OUTPUT_DIRECTORY
"${CMAKE_CURRENT_BINARY_DIR}/${snippet_target_path}")
collect_used_snippet (${target})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ int main()

auto ${source_alphabet}_view = vector | seqan3::views::convert<seqan3::${source_alphabet}>;

for (auto && chr: ${source_alphabet}_view) // converts lazily on-the-fly
for (auto && chr : ${source_alphabet}_view) // converts lazily on-the-fly
{
static_assert(std::same_as<decltype(chr), seqan3::${source_alphabet} &&>);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
int main()
{
//![usage]
std::views::take_while(
auto v = std::views::take_while(
[](auto const & l)
{
return (l != '\r') && (l != '\n');
Expand Down
28 changes: 14 additions & 14 deletions test/snippet/utility/char_operations/char_predicate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,55 +4,55 @@
int main()
{
//! [is_eof]
seqan3::is_eof(EOF); // returns true
seqan3::is_eof('C'); // returns false
static_assert(seqan3::is_eof(EOF));
static_assert(!seqan3::is_eof('C'));
//! [is_eof]

//! [is_cntrl]
seqan3::is_cntrl('\0'); // returns true.
static_assert(seqan3::is_cntrl('\0'));
//! [is_cntrl]

//! [is_print]
seqan3::is_print(' '); // returns true.
static_assert(seqan3::is_print(' '));
//! [is_print]

//! [is_space]
seqan3::is_space('\n'); // returns true.
static_assert(seqan3::is_space('\n'));
//! [is_space]

//! [is_blank]
seqan3::is_blank('\t'); // returns true.
static_assert(seqan3::is_blank('\t'));
//! [is_blank]

//! [is_graph]
seqan3::is_graph('%'); // returns true.
static_assert(seqan3::is_graph('%'));
//! [is_graph]

//! [is_punct]
seqan3::is_punct(':'); // returns true.
static_assert(seqan3::is_punct(':'));
//! [is_punct]

//! [is_alnum]
seqan3::is_alnum('9'); // returns true.
static_assert(seqan3::is_alnum('9'));
//! [is_alnum]

//! [is_alpha]
seqan3::is_alpha('z'); // returns true.
static_assert(seqan3::is_alpha('z'));
//! [is_alpha]

//! [is_upper]
seqan3::is_upper('K'); // returns true.
static_assert(seqan3::is_upper('K'));
//! [is_upper]

//! [is_lower]
seqan3::is_lower('a'); // returns true.
static_assert(seqan3::is_lower('a'));
//! [is_lower]

//! [is_digit]
seqan3::is_digit('1'); // returns true.
static_assert(seqan3::is_digit('1'));
//! [is_digit]

//! [is_xdigit]
seqan3::is_xdigit('e'); // returns true.
static_assert(seqan3::is_xdigit('e'));
//! [is_xdigit]
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ auto fn = [](auto value)
else if constexpr (std::is_same_v<value_t, int>)
return value == 3;
else if constexpr (std::is_same_v<value_t, double>)
return std::abs(value - 1.2) < 0.00001;
return value - 1.2 < 0.00001;
else
return false;
};
Expand Down
Loading

1 comment on commit 57b9924

@vercel
Copy link

@vercel vercel bot commented on 57b9924 Nov 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

seqan3 – ./

seqan3.vercel.app
seqan3-git-master-seqan.vercel.app
seqan3-seqan.vercel.app

Please sign in to comment.