You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
2.1 KiB

пре 11 месеци
пре 11 месеци
пре 11 месеци
пре 11 месеци
пре 11 месеци
пре 11 месеци
  1. cmake_minimum_required(VERSION 3.24)
  2. project(UserScript)
  3. set(CMAKE_CXX_STANDARD 23)
  4. set(CMAKE_VERBOSE_MAKEFILE ON)
  5. set(FETCHCONTENT_QUIET OFF)
  6. set(CATCH_CONFIG_DISABLE_EXCEPTIONS ON)
  7. Include(FetchContent)
  8. FetchContent_Declare(
  9. Catch2
  10. GIT_REPOSITORY https://github.com/catchorg/Catch2.git
  11. GIT_TAG v3.3.2
  12. )
  13. FetchContent_MakeAvailable(Catch2)
  14. enable_testing()
  15. include(CTest)
  16. include(Catch)
  17. add_library(UserScript STATIC
  18. include/UserScript.h
  19. priv_include/UserScript/interpreter.h
  20. src/generator.cpp
  21. src/interpreter.cpp
  22. src/lex.cpp
  23. src/parse.cpp src/std/array.cpp src/std/crypto.cpp include/UserScriptRequire.h include/UserScriptWizardry.h)
  24. target_include_directories(UserScript PUBLIC include)
  25. include_directories(priv_include)
  26. add_executable(ushell script_exe/main.cpp)
  27. target_link_libraries(ushell PUBLIC UserScript)
  28. add_executable(userscript_tests tests/lexer_test.cpp tests/parser_test.cpp)
  29. target_link_libraries(userscript_tests PUBLIC UserScript Catch2::Catch2WithMain)
  30. catch_discover_tests(userscript_tests)
  31. function(add_script_test [testname filename resultname])
  32. message("Added test: ${ARGV0}")
  33. add_test(
  34. NAME "${ARGV0}"
  35. WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
  36. COMMAND $<TARGET_FILE:ushell> "compare" "${ARGV1}" "${ARGV2}"
  37. )
  38. endfunction()
  39. add_script_test("Scripting 001: Operators" tests/scripts/001.script tests/scripts/001.results)
  40. add_script_test("Scripting 002: Statements and Conditionals" tests/scripts/002.script tests/scripts/002.results)
  41. add_script_test("Scripting 003: While loops" tests/scripts/003.script tests/scripts/003.results)
  42. add_script_test("Scripting 004: While loops with bad terminator" tests/scripts/004.script tests/scripts/004.results)
  43. add_script_test("Scripting 005: If statements with bad terminator" tests/scripts/005.script tests/scripts/005.results)
  44. add_script_test("Scripting 006: The stack is properly purged" tests/scripts/006.script tests/scripts/006.results)