dl
dl_script_test.h
浏览该文件的文档.
1
11#pragma once
12
13#include "script/dl_script.h"
14
15namespace dl
16{
17 // 基础
18 constexpr std::string_view SCRIPT_TEST_BASE = R"(
19print "hello dl!"
20)";
21 // 表达式
22 constexpr std::string_view SCRIPT_TEST_EXPR = R"(
23a = 0
24b = 1
25c = 2
26d = 3
27print a + b - c * d / 5
28print "结果应该为0"
29)";
30 // 字符串
31 constexpr std::string_view SCRIPT_TEST_STRING = R"(
32a = "hello"
33b = "dl"
34print a+" "+b+"!"
35)";
36 // 断言
37 constexpr std::string_view SCRIPT_TEST_ASSERT = R"(
38a = 1
39assert a == 1
40assert a == 0
41)";
42 // 作用域
43 constexpr std::string_view SCRIPT_TEST_SCOPE = R"(
44a = 1
45{
46 b = 2
47 print a
48 print b
49 print c
50}
51{
52 c = 3
53 print a
54 print b
55 print c
56}
57print a
58print b
59print c
60)";
61 // vector
62 constexpr std::string_view SCRIPT_TEST_VECTOR = R"(
63a = 13
64vec = { 1,3, 5, 7 ,9 ,11}
65print vec
66)";
67
68 inline void TestScript(std::string_view str)
69 {
70 ScriptBlock block = g_script->Compile(str);
71
72 ScriptVM vm;
73 vm.Execute(block);
74 }
75
85}
void Execute(const ScriptBlock &block)
dl脚本语言
ScriptSystem * g_script
constexpr std::string_view SCRIPT_TEST_SCOPE
void TestScriptAll()
constexpr std::string_view SCRIPT_TEST_EXPR
constexpr std::string_view SCRIPT_TEST_BASE
constexpr std::string_view SCRIPT_TEST_STRING
void TestScript(std::string_view str)
constexpr std::string_view SCRIPT_TEST_ASSERT
constexpr std::string_view SCRIPT_TEST_VECTOR