# Souffle - A Datalog Compiler
# Copyright (c) 2021 The Souffle Developers. All rights reserved
# Licensed under the Universal Permissive License v 1.0 as shown at:
# - https://opensource.org/licenses/UPL
# - <souffle root>/licenses/SOUFFLE-UPL.txt

include(SouffleTests)

if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Linux")
    add_subdirectory(pragma2)
endif()

add_subdirectory(functor_fact)
add_subdirectory(issue2373)


function(positive_test NAME)
    souffle_positive_test(${NAME} semantic ${ARGN})
endfunction()

function(positive_output_stdout_test NAME)
    souffle_run_test_helper(TEST_NAME ${NAME} CATEGORY semantic OUTPUT_STDOUT ${ARGV})
    souffle_run_test_helper(TEST_NAME ${NAME} CATEGORY semantic OUTPUT_STDOUT ${ARGV} COMPILED)
endfunction()

function(negative_test NAME)
    souffle_negative_test(${NAME} semantic)
endfunction()

negative_test(adt_invalid_arity)
negative_test(adt_invalid_branch)
negative_test(agg_checks)
negative_test(agg_checks2)
positive_test(agg_checks3)
positive_test(aggregate1)
positive_test(aggregate2)
positive_test(aggregate3)
positive_test(aggregate4)
positive_test(aggregate5)
positive_test(aggregate6)
positive_test(agg_nested)
positive_test(alias)
negative_test(attrib_dupl)
positive_test(bin1)
positive_test(bin COMPILED_SPLITTED)
positive_test(binhex)
positive_test(bitwise)
positive_test(bool)
negative_test(choice)
negative_test(comp_clauses)
negative_test(comp_infinite_recursion)
positive_test(comp_inner_types)
negative_test(comp_name_resolution)
negative_test(comp_nonexistent_type)
negative_test(comp_override)
negative_test(comp_params_inheritance)
negative_test(comp_relation)
negative_test(comp_types)
positive_test(comp_types2)
positive_test(comp_opt)
negative_test(counter2)
positive_test(counter)
negative_test(disjoint_names)
# TODO (see issue #231) negative_test(divide_by_zero)
positive_test(duplicates)
positive_test(eqrel_tests COMPILED_SPLITTED)
positive_test(eqrel_tests2)
positive_test(eqrel_tests3)
positive_test(eqrel_tests4)
positive_test(equivalent)
negative_test(execution_plan)
positive_test(extended_subtypes)
negative_test(extended_subtypes2)
negative_test(extended_subtypes3)
negative_test(fact_arity)
negative_test(fact_cat)
negative_test(fact_ctr)
negative_test(fact_empty)
negative_test(fact_number2)
negative_test(fact_number)
negative_test(fact_plus)
negative_test(fact_variable)
positive_test(func_in_rec)
positive_test(hex1)
positive_test(hex)
positive_test(identity_functor)
positive_test(identity_functor_inf_loop)
negative_test(inline_cycle1)
positive_test(inline_cycle2)
negative_test(inline_exclude)
negative_test(inline_ungrounded)
negative_test(inline_negation)
negative_test(inline_output)
positive_test(inline_segfault)
positive_test(interval)
positive_test(ipv4)
positive_test(ipv4_1)
souffle_run_test(TEST_NAME json CATEGORY semantic EXTRA_DATA json)
souffle_run_test(TEST_NAME jsonfile CATEGORY semantic EXTRA_DATA json)
negative_test(keys)
positive_test(keys1)
positive_test(keys2)
positive_test(leq COMPILED_SPLITTED)
positive_test(limitsize)
negative_test(load2)
negative_test(load3)
negative_test(load4)
if (SOUFFLE_USE_ZLIB)
positive_test(load6)
endif ()
positive_test(load7)
positive_test(load8)
positive_test(load9)
negative_test(load10)
positive_test(load11)
positive_test(load12)
positive_test(load13)
positive_test(load_adt)
positive_test(load_adt2)
positive_test(load_adt3)
positive_test(load_record_delimiter)
positive_test(load_record_large)
positive_test(load_record_large2)
negative_test(load_record_invalid_parenthesis)
positive_test(load_simple_record)
positive_test(load_simple_record2)
positive_test(load_symbol_in_record)
positive_test(logical)
positive_test(lrg_attr_id COMPILED_SPLITTED)
positive_test(lrg_rel_id1)
positive_test(lrg_rel_id2)
positive_test(negative_numbers)
positive_test(not_copy1)
positive_test(not_copy2)
positive_test(not_copy)
negative_test(plan1)
negative_test(plan2)
positive_test(plan3)
positive_test(progmin1)
positive_test(progmin2)
positive_test(range)
negative_test(record_null)
positive_test(records0)
positive_test(records1)
positive_test(records2)
positive_test(records3)
positive_test(records4)
positive_test(records5)
positive_test(records6)
positive_test(records7)
positive_test(records8)
positive_test(records9)
negative_test(recursive_unions)
negative_test(recursive_unions2)
positive_test(rel_copy_cycles)
negative_test(rel_dupl)
positive_test(rel_list)
positive_test(rel_nullary)
negative_test(rel_stratification2)
negative_test(rel_stratification)
negative_test(rel_udef)
positive_test(rqualifiers)
negative_test(rule_arity)
negative_test(rule_grounded)
negative_test(rule_typecompat)
negative_test(rule_undeclared_relation2)
negative_test(rule_undeclared_relation)
if (SOUFFLE_USE_ZLIB)
    souffle_run_test(TEST_NAME store CATEGORY semantic EXTRA_DATA gzip)
endif()
positive_test(store2)
if (SOUFFLE_USE_SQLITE)
    souffle_run_test(TEST_NAME store3 CATEGORY semantic EXTRA_DATA sqlite3)
    souffle_run_test(TEST_NAME store6 CATEGORY semantic EXTRA_DATA sqlite3)
endif()
positive_test(store4)
positive_test(store5)
positive_test(store_adt)
positive_test(store_adt2)
positive_test(store_adt3)
positive_test(store_record_multilevel)
positive_test(store_record_large)
positive_test(store_record_one_level)
positive_test(strconv)
positive_test(string_len)
positive_test(string_minmax)
positive_test(string_substr1 COMPILED_SPLITTED)
positive_test(string_substr COMPILED_SPLITTED)
positive_test(suppress_warnings)
negative_test(subsumption)
positive_test(subsumption_multiple_rules COMPILED_SPLITTED)
positive_test(type_as)
negative_test(type_as2)
negative_test(type_as3)
negative_test(type_dupl)
negative_test(type_system1)
negative_test(type_system2)
negative_test(type_system3)
positive_test(type_system4)
positive_test(type_system5)
negative_test(type_system6)
negative_test(type_system7)
positive_test(type_system8)
positive_test(type_system9)
positive_test(type_system10)
negative_test(type_system11)
negative_test(type_system12)
negative_test(type_system13)
negative_test(type_system14)
negative_test(type_system15)
negative_test(type_system16)
positive_test(type_system_negation)
negative_test(type_system_sum_types)
negative_test(type_system_sum_types2)
positive_test(type_system_records)
negative_test(type_system_records2)
negative_test(type_udef)
positive_test(types_components)
negative_test(undeclared_udfs)
positive_test(underscore2)
positive_test(underscore3)
positive_test(underscore4)
negative_test(underscore)
negative_test(union_types)
negative_test(var_single)
negative_test(witness_check)
positive_test(adt_access)
negative_test(bad_functor_types)
positive_test(choice1)
# positive_test(comparison) TODO See PR #1932
negative_test(disjoint_names2)
positive_test(pragma)
positive_test(pragma1)
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Linux")
	# Only test `pragma2` w/ interpreter mode.
	# Reason: Linux tooling becomes violently incontinent when confronted with the
	#         idea of an so w/ non alpha-numeric characters in the name.
	#         See `tests/semantic/pragma2/CMakeLists.txt` for details.
	# souffle_positive_functor_test(pragma2 CATEGORY semantic)
	souffle_run_test_helper(TEST_NAME pragma2 FUNCTORS CATEGORY semantic)
endif()
positive_test(rel_redundant)
positive_test(type_as4)
positive_test(record_alias)
positive_test(record_alias2)
positive_test(adt_alias)
if (FALSE)
# semantics checker of complex rule does not catch this
# "variable only occurs once" issue.
positive_test(complex_rule)
endif ()
positive_test(compose_components)
positive_test(inherit_argument)
positive_test(inherit_argument_override)
positive_test(inherit_instance)
positive_test(inherit_instance_override)
positive_test(instantiate_from_inherited)
positive_test(instantiate_from_inherited_override)
souffle_positive_functor_test(functor_fact CATEGORY semantic)
positive_test(underscore5)
negative_test(mutually_dependent_aggregate)
positive_test(independent_aggregate)
positive_test(independent_aggregate2)
souffle_positive_functor_test(issue2373 CATEGORY semantic)
negative_test(error_deduce_type)
positive_output_stdout_test(output_stdout)
positive_test(iteration_counter)
positive_test(issue1896)
positive_test(comp_params)
positive_test(issue2416)
positive_test(agg_range)
positive_test(issue2482)
