49 KiB
TSL Agent Codegen Prompt Tests
This file defines manual prompt tests for evaluating whether an agent can read
docs/tsl and produce syntactically correct TSL code on the first attempt.
These are not TSL language docs. They are agent evaluation prompts. Keep grammar
facts in docs/tsl; keep agent test prompts here.
How To Run
For each case:
- Start from a fresh agent context that has access to this repository.
- Send only the
Prompttext to the agent unless the test runner has a standard system prompt. - Allow the agent to read
docs/tsl. - Score the first complete answer only. Do not let the agent revise.
- Record pass/fail against the
Pass criteria.
Recommended runner setup:
You are in this repository. TSL grammar and reference docs are under docs/tsl.
When asked to write TSL, read the relevant docs/tsl pages first. Do not infer
syntax from Pascal, TypeScript, JavaScript, Python, or SQL.
Scoring
2= first answer satisfies all pass criteria.1= mostly correct, but has one minor issue that does not change the tested grammar point.0= wrong file model, invalid TSL syntax, invented syntax, or missed the tested grammar point.
Track these aggregate metrics:
- Overall first-pass accuracy.
- Accuracy by topic group.
- Most common failure patterns.
- Whether failures came from not reading docs, reading the wrong docs page, or overfitting to another language.
Global Failure Patterns
Flag these as failures whenever they appear in generated code:
- Uses
=for ordinary assignment instead of:=. - Uses comma separators in a typed parameter list, such as
function Add(a: integer, b: integer): integer. - Writes named arguments as
a = 1instead ofa: 1. - Writes a
.tslscript as only top-level reusable declarations when executable script behavior was requested. - Appends executable script statements after a
.tslfunction or class declaration section. - Writes a top-level class as
class Name ... end;instead oftype Name = class ... end;. - Uses bare class names for class functions or static fields instead of
class(Name). - Invents syntax not documented in
docs/tsl.
Test Cases
TSL-001: Typed Add Function
Prompt:
请根据本仓库 docs/tsl 的语法,写一个 TSL 加法函数 Add。
要求两个参数都有整数类型,返回值也要有整数类型。
只输出代码。
Expected focus:
- Basic
functiondeclaration. - Typed parameters and typed return value.
Pass criteria:
- Uses
function Add(a: integer; b: integer): integer;. - Uses
return a + b;. - Uses
begin ... end;. - Does not separate typed parameters with commas.
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-002: Executable Script Calling A Local Function
Prompt:
写一段可执行的 .tsl 脚本:计算 1 + 2,并用 writeLn 输出结果。
加法逻辑封装成 Add 函数,脚本里调用它。
只输出代码。
Expected focus:
.tslfile model.- Executable statements before local function declarations.
Pass criteria:
- Script statements appear before the
function Add...declaration. - Calls
writeLn(Add(1, 2));or an equivalent statement before declarations. - Does not append executable statements after the function declaration.
- Uses
:=for ordinary assignments if assignments are introduced.
Source docs:
docs/tsl/syntax/01_quickstart.mddocs/tsl/syntax/02_core_model.mddocs/tsl/syntax/05_functions_and_calls.md
TSL-003: Reusable Function File
Prompt:
我要一个可复用的 .tsf 函数扩展文件,里面只有一个函数 IsPositive,
输入整数 x,返回 x 是否大于 0。只输出代码。
Expected focus:
.tsfreusable declaration model.- No executable script entry statements.
Pass criteria:
- Outputs a top-level
function IsPositive(x: integer);or typed return variant if supported by the chosen evidence. - Function body returns
x > 0. - Does not add
.tslentry statements such aswriteLn(...). - Does not invent an undocumented
booleanreturn type.
Source docs:
docs/tsl/syntax/01_quickstart.mddocs/tsl/syntax/02_core_model.mddocs/tsl/syntax/05_functions_and_calls.md
TSL-004: Procedure With Write-Back Parameter
Prompt:
写一段 .tsl 脚本,定义一个过程 Bump,把传入变量加 1。
脚本里先把 a 设为 1,调用 Bump(a),再输出 a。只输出代码。
Expected focus:
procedureonly when explicitly requested.varparameter write-back..tsldeclaration section order.
Pass criteria:
- Uses
procedure Bump(var x);. - Assigns
a := 1;before callingBump(a);. - Outputs
abefore the procedure declaration section. - Does not put a return type on the
procedureheader.
Source docs:
docs/tsl/syntax/05_functions_and_calls.mddocs/tsl/syntax/02_core_model.md
TSL-005: Named Parameter Call
Prompt:
写一个 TSL 示例,定义函数 MakePair(a, b),返回 array(a, b)。
调用时必须使用命名参数,把 b 传 20,把 a 传 10,并输出两个元素。
只输出代码。
Expected focus:
- Named argument syntax.
- Array indexing.
Pass criteria:
- Calls the function with
MakePair(b: 20, a: 10)or equivalent named argument order. - Does not use
MakePair(b = 20, a = 10). - Reads array elements with zero-based array indexes.
- Keeps executable statements before the function declaration in
.tsl.
Source docs:
docs/tsl/syntax/05_functions_and_calls.mddocs/tsl/syntax/12_matrix_and_collections.md
TSL-006: Default Variable Model
Prompt:
写一段最简单的 TSL 脚本:把 3 赋给 a,把 4 赋给 b,
再输出 a * b。不要做多余声明。只输出代码。
Expected focus:
- Ordinary variables do not need a
vardeclaration by default. - Assignment operator.
Pass criteria:
- Uses
a := 3;andb := 4;. - Does not use
a = 3;orb = 4;. - Does not add unnecessary
vardeclarations.
Source docs:
docs/tsl/syntax/04_variables_and_constants.mddocs/tsl/syntax/06_expressions_and_operators.md
TSL-007: Explicit Variable Mode
Prompt:
写一段 TSL 脚本,开启 explicit 模式,声明变量 total,
把 total 设置为 0,然后输出它。只输出代码。
Expected focus:
{$explicit+}.- Explicit
vardeclaration.
Pass criteria:
- Starts with
{$explicit+}or places it before first undeclared variable use. - Declares
var total;. - Assigns with
total := 0;.
Source docs:
docs/tsl/syntax/04_variables_and_constants.mddocs/tsl/syntax/16_lexical_structure_and_compile_options.md
TSL-008: Constant Initialization
Prompt:
写一段 TSL 脚本,定义常量 max_count 为 3 + 4,
然后输出 max_count。只输出代码。
Expected focus:
const name = value;is constant initialization, not ordinary assignment.
Pass criteria:
- Uses
const max_count = 3 + 4;. - Outputs
max_count. - Does not later assign to
max_count.
Source docs:
docs/tsl/syntax/04_variables_and_constants.mddocs/tsl/syntax/06_expressions_and_operators.md
TSL-009: Single-Variable Destructuring
Prompt:
写一段 TSL 脚本,从 array(7, 8, 9) 里只拆出第一个值到 first,
然后输出 first。只输出代码。
Expected focus:
- Single-variable destructuring keeps the trailing comma.
Pass criteria:
- Uses
[first, ] := array(7, 8, 9);. - Does not use
[first] := ....
Source docs:
docs/tsl/syntax/04_variables_and_constants.mddocs/tsl/syntax/06_expressions_and_operators.md
TSL-010: If Else Block
Prompt:
写一段 TSL 脚本:如果 score >= 60,就把 result 设为 "pass",
否则设为 "fail",最后输出 result。score 设为 70。只输出代码。
Expected focus:
- Block-style
if ... then begin ... end else begin ... end. - No semicolon between
thenblockendandelse.
Pass criteria:
- Uses
if score >= 60 thenfollowed by a valid block. - Does not put a semicolon after the
thenbranchendbeforeelse. - Outputs after the conditional block, not inside only one branch.
Source docs:
docs/tsl/syntax/07_control_flow.md
TSL-011: For Loop With Step
Prompt:
写一段 TSL 脚本,用 for 循环计算 1、3、5 的和并输出。
要求使用 step。只输出代码。
Expected focus:
for i := 1 to 5 step 2 do.
Pass criteria:
- Uses
for i := 1 to 5 step 2 do. - Accumulates with
:=or+=. - Outputs
9or the computed sum variable.
Source docs:
docs/tsl/syntax/07_control_flow.md
TSL-012: Array Traversal
Prompt:
写一段 TSL 脚本,遍历 array(10, 20, 30),每行输出索引和值的和。
必须使用 for i, v in data。只输出代码。
Expected focus:
- Array traversal form.
- Zero-based index behavior.
Pass criteria:
- Uses
for i, v in data do. - Uses
data := array(10, 20, 30);. - Does not invent Python-style or JavaScript-style iteration syntax.
Source docs:
docs/tsl/syntax/07_control_flow.md
TSL-013: Array And String Indexing
Prompt:
写一段 TSL 脚本,创建 array(10, 20, 30) 和字符串 "ABC"。
输出数组第一个元素,再输出字符串第一个字符。只输出代码。
Expected focus:
- Arrays are zero-based.
- Strings are one-based.
Pass criteria:
- Reads the first array element with
arr[0]. - Reads the first string character with
s[1]. - Does not use
s[0].
Source docs:
docs/tsl/syntax/01_quickstart.mddocs/tsl/syntax/03_values_and_literals.mddocs/tsl/syntax/11_pitfalls.md
TSL-014: Hash-Like Array
Prompt:
写一段 TSL 脚本,用 array 创建一个带字符串键的表,
包含 Code = "0001" 和 Price = 12.3,然后输出 Code。只输出代码。
Expected focus:
array("Code": "0001", "Price": 12.3).
Pass criteria:
- Uses string-key
array(...)syntax. - Reads with
hash["Code"]or equivalent variable name.
Source docs:
docs/tsl/syntax/12_matrix_and_collections.md
TSL-015: in Versus sqlin
Prompt:
写一段 TSL 脚本,同时演示:
1 是否属于 array(1, 2),以及 array(1, 2) 这一整行是否存在于
array((1, 2), (3, 4))。分别输出两个判断结果。只输出代码。
Expected focus:
- Element/subset relation uses
in. - Whole-row relation uses
sqlin.
Pass criteria:
- Uses
1 in array(1, 2). - Uses
array(1, 2) sqlin array((1, 2), (3, 4)). - Does not use
infor the whole-row test.
Source docs:
docs/tsl/syntax/12_matrix_and_collections.md
TSL-016: Explicit String To Integer Conversion
Prompt:
写一段 TSL 脚本,把字符串 "1234" 转成整数后加 1,
再输出结果。只输出代码。
Expected focus:
- Explicit conversion instead of relying on mixed-type arithmetic.
Pass criteria:
- Uses
strToInt(...). - Does not directly compute
"1234" + 1.
Source docs:
docs/tsl/syntax/17_types_and_conversions.md
TSL-017: Nil Handling
Prompt:
写一段 TSL 脚本,创建空数组 arr,判断 arr[0] 是否为 nil,
并输出判断结果。只输出代码。
Expected focus:
- Empty array missing element returns
nil. - Explicit nil comparison.
Pass criteria:
- Uses
arr := array();. - Checks
arr[0] = nilor uses documentedifNil(...). - Does not invent
null,None, orundefined.
Source docs:
docs/tsl/syntax/17_types_and_conversions.md
TSL-018: Regex-Like
Prompt:
写一段 TSL 脚本,判断字符串 "abc" 是否匹配以 a 开头的模式,
用 like 运算符,并输出结果。只输出代码。
Expected focus:
likeright side is regex-like, not SQL%wildcard.
Pass criteria:
- Uses a regex-style pattern such as
"^a.*"or another documented-compatible regex pattern. - Does not use
"a%"as the pattern.
Source docs:
docs/tsl/syntax/06_expressions_and_operators.mddocs/tsl/syntax/11_pitfalls.md
TSL-019: Basic Class
Prompt:
写一段 .tsl 脚本,定义 Person 类,包含 public 字段 name。
脚本里创建 Person,把 name 设为 "Tom",然后输出 name。只输出代码。
Expected focus:
- Top-level class declaration syntax.
.tslexecutable statements before class declaration section.
Pass criteria:
- Uses
type Person = class. - Includes
publicbeforename;. - Creates with
new Person(). - Does not write
class Person. - Does not append executable statements after the class declaration.
Source docs:
docs/tsl/syntax/08_objects_and_classes.mddocs/tsl/syntax/02_core_model.md
TSL-020: Public Constructor
Prompt:
写一段 .tsl 脚本,定义 Counter 类。
构造函数接收初始值 v,保存到 value;Inc 方法把 value 加 1 并返回。
脚本里 new Counter(10),输出 Inc 的结果。只输出代码。
Expected focus:
function create(...)constructor underpublic.- Instance method body accesses members directly.
Pass criteria:
- Defines
type Counter = class. - Puts
function create(v);in apublicsection. - Uses
value := v;increate. - Uses
value := value + 1; return value;or equivalent inInc. - Does not make
createprivate or protected.
Source docs:
docs/tsl/syntax/08_objects_and_classes.md
TSL-021: Static Field Access
Prompt:
写一段 TSL 示例,定义 THuman 类,包含 static 字段 mCount。
先把 mCount 设置为 100,再输出它。只输出代码。
Expected focus:
- Static field access through class type.
Pass criteria:
- Defines
static mCount;. - Sets or reads it through
class(THuman).mCount. - Does not use
THuman.mCount.
Source docs:
docs/tsl/syntax/08_objects_and_classes.mddocs/tsl/syntax/11_pitfalls.md
TSL-022: Class Function Access
Prompt:
写一个 TSL 类 MathBox,里面有 class function Add(a, b),返回 a + b。
再写脚本输出 MathBox 的 Add(1, 2) 结果。只输出代码。
Expected focus:
- Class function declaration.
- Class function call through class type.
Pass criteria:
- Defines a
class function Add(a, b);insidetype MathBox = class. - Calls via
class(MathBox).Add(1, 2)or another documented class-type path. - Does not call
MathBox.Add(1, 2). - Keeps executable call before the class declaration in
.tsl.
Source docs:
docs/tsl/syntax/08_objects_and_classes.mddocs/tsl/syntax/11_pitfalls.md
TSL-023: Full Unit Skeleton
Prompt:
写一个 .tsf unit,名字是 DemoUnit。
对外暴露函数 Ping,调用返回 1。使用完整 interface / implementation 结构。
只输出代码。
Expected focus:
- Full
unitstructure. end.terminator.
Pass criteria:
- Starts with
unit DemoUnit;. - Has
interfaceandimplementationsections. - Declares
function Ping();ininterface. - Implements
function Ping(); begin return 1; end;. - Ends the unit with
end..
Source docs:
docs/tsl/syntax/09_units_and_scope.mddocs/tsl/syntax/01_quickstart.md
TSL-024: Top-Level uses Before Statements
Prompt:
写一段 .tsl 脚本,使用 UnitA 和 UnitB 两个 unit,
然后调用 Run() 并输出结果。注意 uses 的位置。只输出代码。
Expected focus:
- Top-level
usesbefore ordinary statements. - Multiple units in one
usesstatement.
Pass criteria:
- Uses
uses UnitA, UnitB;before executable statements. - Does not write ordinary statements before top-level
uses. - Does not generate two separate top-level
usesstatements as the default.
Source docs:
docs/tsl/syntax/09_units_and_scope.mddocs/tsl/syntax/11_pitfalls.md
TSL-025: Function-Body uses Placement
Prompt:
写一个 TSL 函数 RunInFunction,函数体内使用 DemoUnit,
然后返回 Ping()。只输出这个函数代码。
Expected focus:
- Function-body
usesmust be the first statement.
Pass criteria:
- Writes
uses DemoUnit;as the first statement afterbegin. - Does not put any assignment or other statement before function-body
uses. - Does not repeat
usesinside the same function body.
Source docs:
docs/tsl/syntax/09_units_and_scope.md
TSL-026: Try Except
Prompt:
写一段 TSL 脚本,用 try/except 捕获 raise "bad",
在 except 中输出 exceptObject.errInfo。只输出代码。
Expected focus:
- TSL exception syntax.
exceptObjectfields.
Pass criteria:
- Uses
try ... except ... end. - Raises with
raise "bad". - Reads
exceptObject.errInfoin theexceptblock.
Source docs:
docs/tsl/syntax/07_control_flow.md
TSL-027: Ambiguous File Model
Prompt:
帮我写一个 TSL 的加法函数。
Expected focus:
- Handling an underspecified user request.
- Avoiding invented file model assumptions.
Pass criteria:
- Either produces only a minimal reusable function declaration, or explicitly states the file-model assumption before the code.
- Uses
function, notprocedure. - Does not generate invalid
.tsldeclaration ordering. - Does not invent parameter types if the prompt did not require them.
Source docs:
docs/tsl/index.mddocs/tsl/syntax/01_quickstart.mddocs/tsl/syntax/02_core_model.mddocs/tsl/syntax/05_functions_and_calls.md
TSL-028: Bad Prompt With Type Requirement
Prompt:
帮我写一个tsl代码,写一个加法,需要参数类型和返回类型。
Expected focus:
- Robustness to informal Chinese prompts.
- Correct typed function syntax.
Pass criteria:
- Uses a
functionwith typed parameters and typed return value. - Uses semicolons between typed parameters.
- Uses
return a + b;. - Does not use TypeScript-like syntax such as
function add(a: number, b: number): number.
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-029: Anti-Pascal Assignment Trap
Prompt:
写一段 TSL 脚本,把 a 设为 1,把 b 设为 2,
如果 a + b 等于 3 就输出 "ok"。只输出代码。
Expected focus:
- Ordinary assignment versus equality comparison.
Pass criteria:
- Uses
a := 1;andb := 2;. - Uses
=only in the comparison expression. - Does not use
==.
Source docs:
docs/tsl/syntax/06_expressions_and_operators.mddocs/tsl/syntax/11_pitfalls.md
TSL-030: No Script After Declaration Trap
Prompt:
写一段 .tsl 脚本:先调用 Hello(),Hello 输出 "hello"。
调用完成后再输出 "done"。只输出代码。
Expected focus:
- All executable script statements must be before the declaration section.
- A natural prompt order can tempt the agent to put
writeLn("done")afterfunction Hello.
Pass criteria:
- Places both
Hello();and the statement that outputs"done"beforefunction Hello();. - Defines
Helloafter the executable statements. - Does not append the
"done"output statement after the function declaration.
Source docs:
docs/tsl/syntax/01_quickstart.mddocs/tsl/syntax/02_core_model.mddocs/tsl/syntax/11_pitfalls.md
Extended Compact Cases
The first 30 cases above are detailed baseline cases. The following compact cases broaden grammar coverage while keeping each prompt independently runnable.
TSL-031: Numeric Literal Types
Prompt:
写一段 TSL 脚本,分别输出 0x10、0b10、0o10、100L、1E2 的类型判断结果。
只输出代码。
Pass criteria:
- Uses documented numeric literals.
- Uses type checks such as
ifInt,ifInt64, andifReal. - Does not rewrite the literals into decimal-only values.
Source docs:
docs/tsl/syntax/17_types_and_conversions.md
TSL-032: Date Time Literals
Prompt:
写一段 TSL 脚本,创建 20111231T 和 20101231.0931T,
并分别输出日期和时间字符串。只输出代码。
Pass criteria:
- Uses documented date-time literal forms.
- Uses documented conversion helpers such as
dateToStrandtimeToStr. - Does not invent ISO string literal syntax.
Source docs:
docs/tsl/syntax/17_types_and_conversions.md
TSL-033: Boolean And Numeric Truthiness
Prompt:
写一段 TSL 脚本,输出 true、false,并演示 if 2、if 0、if -1 的判断结果。
只输出代码。
Pass criteria:
- Uses
trueandfalsedirectly. - Treats
0as false and non-zero numeric values as true. - Does not invent
True/Falsecapitalization.
Source docs:
docs/tsl/syntax/17_types_and_conversions.md
TSL-034: Nil Arithmetic Boundary
Prompt:
写一段 TSL 脚本,输出 ifNil(nil)、nil + 1、1 + nil,
以及 nil + nil 是否仍为 nil。只输出代码。
Pass criteria:
- Uses
nil, notnull,None, orundefined. - Uses
ifNil(nil)or documentednilcomparison. - Does not reject
nil + 1as invalid syntax.
Source docs:
docs/tsl/syntax/17_types_and_conversions.md
TSL-035: Complex Number Basics
Prompt:
写一段 TSL 脚本,创建复数 4 + 3j 和 complex(5, -2),
输出第一个复数的 real、imag 和 ifComplex 判断。只输出代码。
Pass criteria:
- Uses
4 + 3jorcomplex(real, imag)as documented. - Uses
real(...),imag(...), andifComplex(...). - Does not invent Python object methods such as
.real.
Source docs:
docs/tsl/syntax/17_types_and_conversions.md
TSL-036: String Concatenation
Prompt:
写一段 TSL 脚本,把 "TS" 和 "L" 拼成 "TSL" 并输出。
使用 docs/tsl 里确认的字符串连接写法。只输出代码。
Pass criteria:
- Uses documented string concatenation with
+or$. - Uses TSL string literals.
- Does not call undocumented helpers such as
concat(...).
Source docs:
docs/tsl/syntax/03_values_and_literals.mddocs/tsl/syntax/06_expressions_and_operators.md
TSL-037: Arithmetic Operator Coverage
Prompt:
写一段 TSL 脚本,分别输出 9 div 4、9 mod 4、2 ^ 3、8 ~ 2、3 \ 2。
只输出代码。
Pass criteria:
- Uses
div,mod,^,~, and\as documented. - Does not replace them with JavaScript-style operators.
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-038: Conditional Expression
Prompt:
写一段 TSL 脚本,a 小于 b 时 value 为 10,否则为 20,
要求使用条件表达式并输出 value。只输出代码。
Pass criteria:
- Uses
condition ? true_value : false_value. - Uses
:=for assignments. - Does not invent
?:placement from C/JS incorrectly.
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-039: Omitted-True Conditional Expression
Prompt:
写一段 TSL 脚本,分别输出 2 ?: 9 和 0 ?: 9 的结果。只输出代码。
Pass criteria:
- Uses the documented
value ?: fallbackform. - Does not rewrite it as a normal
ifstatement unless it preserves the tested expression form.
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-040: Logical Operators
Prompt:
写一段 TSL 脚本,使用 and、or、not 组合两个条件,并输出结果。
只输出代码。
Pass criteria:
- Uses
and,or, andnot. - Does not use
!as logical negation.
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-041: Bitwise Operators
Prompt:
写一段 TSL 脚本,对两个整数演示位与、位或、位非、位异或,
并输出结果。只输出代码。
Pass criteria:
- Uses dot-prefixed bitwise operators such as
.&,.|,.!, and.^. - Does not use ordinary
&,|, or~as bitwise operators.
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-042: Compound Assignment And Increment
Prompt:
写一段 TSL 脚本,a 初始为 1,先用复合赋值加 2,
再自增一次,最后输出 a。只输出代码。
Pass criteria:
- Uses documented
+=anda++or++a. - Initializes with
a := 1;. - Does not use
a = a + 2.
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-043: Nil-Safe Access
Prompt:
写一段 TSL 示例,安全读取可能为 nil 的对象成员 value,
使用 docs/tsl 里的空安全访问写法。只输出代码。
Pass criteria:
- Uses documented nil-safe access such as
obj?.value. - Does not invent optional chaining forms beyond the documented patterns.
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-044: Scalar Chain Comparison
Prompt:
写一段 TSL 脚本,判断 1 < 2 < 3 的连续标量比较并输出结果。
使用 docs/tsl 的链式比较写法。只输出代码。
Pass criteria:
- Uses scalar chain comparison such as
1 :< 2 :< 3. - Does not write Python-style
1 < 2 < 3.
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-045: Matrix-Like Chain Comparison
Prompt:
写一段 TSL 脚本,对 array(1, 2, -1)、array(2, 1, 0)、array(3, 2, 1)
做逐元素链式小于比较,并输出结果数组的三个元素。只输出代码。
Pass criteria:
- Uses matrix chain comparison such as
::<. - Reads result array elements by zero-based indexes.
- Does not use scalar
:<for array-wise comparison.
Source docs:
docs/tsl/syntax/12_matrix_and_collections.mddocs/tsl/syntax/06_expressions_and_operators.md
TSL-046: Default Parameter
Prompt:
写一个 TSL 函数 AddOne,参数 a 默认值为 1,返回 a + 1。
再写脚本输出 AddOne() 和 AddOne(5)。只输出代码。
Pass criteria:
- Uses
function AddOne(a = 1);. - Calls the function before the
.tsldeclaration section. - Does not use unsupported default-parameter syntax.
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-047: Typed Default Parameter
Prompt:
写一个 TSL 函数 TypedAdd,参数 a 是 integer,默认值为 1,
返回值是 integer,返回 a + 1。只输出代码。
Pass criteria:
- Uses
function TypedAdd(a: integer = 1): integer;. - Does not separate typed parameters with commas.
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-048: Named Parameter Skipping Middle Argument
Prompt:
写一段 TSL 脚本,定义 TestFunc(a, b, c),调用 TestFunc(1, c: 3),
在函数里输出 b 是否为 nil。只输出代码。
Pass criteria:
- Uses named parameter syntax
c: 3. - Checks skipped
bwithifNil(b)or documented nil comparison. - Keeps executable call before the function declaration.
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-049: call With Named Parameters
Prompt:
写一段 TSL 脚本,通过 call 调用 TestFunc,并用命名参数传 a、b、c。
TestFunc 返回 a * 100 + b * 10 + c。只输出代码。
Pass criteria:
- Uses
call("TestFunc", a: ..., b: ..., c: ...). - Does not write named arguments with
=. - Defines
TestFuncafter the call in.tsl.
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-050: varByRef Switch
Prompt:
写一段 TSL 脚本,演示 {$varByRef-} 下未修饰参数不写回,
但 var 参数仍会写回。只输出代码。
Pass criteria:
- Uses
{$varByRef-}and later restores if needed with{$varByRef+}. - Includes one unmodified parameter function and one
varparameter function. - Does not rely on another language's value/reference model.
Source docs:
docs/tsl/syntax/05_functions_and_calls.mddocs/tsl/syntax/16_lexical_structure_and_compile_options.md
TSL-051: in And out Call Prefixes
Prompt:
写一段 TSL 脚本,在 {$varByRef-} 下调用 Touch3(in a, out b, c),
演示只有 b 被写回。只输出代码。
Pass criteria:
- Uses call-site prefixes
inandout. - Uses
{$varByRef-}. - Does not write
in/outas type annotations in the function header.
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-052: exit Boundary
Prompt:
写一段 TSL 脚本,函数 Demo(x) 在 x > 0 时 exit,
否则 return 99;输出 Demo(1) 和 Demo(0)。只输出代码。
Pass criteria:
- Uses
exit;inside the function. - Uses
return 99;for the other branch. - Does not treat
exitas returning an explicit custom value.
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-053: Variadic Sum
Prompt:
写一个 TSL 可变参数函数 SumAll(...),遍历 Params 求和并返回。
再输出 SumAll(1, 2, 3, 4)。只输出代码。
Pass criteria:
- Uses
function SumAll(...);. - Iterates
Params. - Does not invent JavaScript rest syntax.
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-054: ParamCount And RealParamCount
Prompt:
写一个 TSL 函数 CountArgs(a, b, ...),返回 ParamCount * 10 + RealParamCount。
输出 CountArgs(1, 2, 3, 4)。只输出代码。
Pass criteria:
- Uses
ParamCountandRealParamCount. - Uses trailing
...in the function header.
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-055: Variadic Forward With call
Prompt:
写一段 TSL 脚本,DoFunc(fc, ...) 通过 call(fc, ...) 转发参数给 Sum3。
输出 DoFunc("Sum3", 1, 2, 3)。只输出代码。
Pass criteria:
- Uses
call(fc, ...). - Uses
function DoFunc(fc, ...);. - Does not manually unpack a fixed number of variadic arguments.
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-056: Anonymous Function Variable
Prompt:
写一段 TSL 脚本,把匿名函数赋给变量 a,
匿名函数返回 x + y,然后用 call(a, 1, 2) 输出结果。只输出代码。
Pass criteria:
- Uses
a := function(x, y) begin ... end;. - Calls via
call(a, 1, 2)or documented##a(...). - Does not call the function variable only as
a(1, 2).
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-057: Anonymous Function As Argument
Prompt:
写一段 TSL 脚本,定义 Apply(fun),内部 call(fun, 2, 3)。
调用 Apply 时直接传入一个匿名乘法函数。只输出代码。
Pass criteria:
- Passes
function(x, y) begin ... endas an argument. - Uses
call(fun, 2, 3)insideApply.
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-058: findFunction Call
Prompt:
写一段 TSL 脚本,用 findFunction("Add") 找到 Add 函数,
再用文档支持的函数值调用方式输出 Add(1, 2)。只输出代码。
Pass criteria:
- Uses
findFunction("Add"). - Calls the returned function with
##f(...)orcall(f, ...). - Does not call
f(...)directly.
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-059: thisFunction Call
Prompt:
写一段 TSL 脚本,用 thisFunction(Add) 得到函数值,
再通过一个 Call 包装函数调用它。只输出代码。
Pass criteria:
- Uses
thisFunction(Add). - Calls the function value with
call(...)or documented wrapper style. - Does not quote
Addif usingthisFunction.
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-060: Global Function Qualification
Prompt:
写一段 TSL 示例,局部函数名和全局/系统函数同名时,
用 docs/tsl 里明确的全局函数限定调用写法。只输出代码。
Pass criteria:
- Uses
::FuncName(...)for global/system function qualification. - Does not invent namespace separators from other languages.
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-061: Case Statement With Range
Prompt:
写一段 TSL 脚本,a 为 4,用 case 判断:
1,2 输出 small;3 到 5 输出 mid;其他输出 other。只输出代码。
Pass criteria:
- Uses
case a of. - Uses comma labels and
3 to 5. - Uses
elseand closes withend.
Source docs:
docs/tsl/syntax/07_control_flow.md
TSL-062: Case Expression
Prompt:
写一段 TSL 脚本,用 case 表达式给 value 赋值,
a 为 2 时 value 是 "two",否则是 "other",然后输出 value。只输出代码。
Pass criteria:
- Uses
value := case ... of ... else ... end;. - Does not put
begin ... endblocks inside expression-form branches.
Source docs:
docs/tsl/syntax/07_control_flow.md
TSL-063: Repeat Until
Prompt:
写一段 TSL 脚本,用 repeat ... until 把 counter 从 3 减到 0,
最后输出 counter。只输出代码。
Pass criteria:
- Uses
repeat ... until counter = 0;. - Does not write
do whilesyntax.
Source docs:
docs/tsl/syntax/07_control_flow.md
TSL-064: Break In While Loop
Prompt:
写一段 TSL 脚本,用 while true 循环累加 1 到 3,
i 大于 3 时 break,然后输出 sum。只输出代码。
Pass criteria:
- Uses
while true do. - Uses
break;inside the loop. - Uses TSL block structure for multi-statement loop body.
Source docs:
docs/tsl/syntax/07_control_flow.md
TSL-065: Continue In While Loop
Prompt:
写一段 TSL 脚本,while 循环 i 从 1 到 4,
跳过 i = 2,只累加其他值并输出 sum。只输出代码。
Pass criteria:
- Uses
continue;for the skipped iteration. - Does not put the increment after a
continuepath that would cause an infinite loop.
Source docs:
docs/tsl/syntax/07_control_flow.md
TSL-066: Try Finally
Prompt:
写一段 TSL 脚本,用 try/finally,try 中输出 "run",
finally 中输出 "cleanup"。只输出代码。
Pass criteria:
- Uses
try ... finally ... end. - Does not use
catchor JavaScript-style exception syntax.
Source docs:
docs/tsl/syntax/07_control_flow.md
TSL-067: Exception Metadata
Prompt:
写一段 TSL 脚本,raise "bad" 后在 except 中输出 errInfo、errLine、errNo。
只输出代码。
Pass criteria:
- Uses
exceptObject.errInfo,exceptObject.errLine, andexceptObject.errNo. - Uses
try ... except ... end.
Source docs:
docs/tsl/syntax/07_control_flow.md
TSL-068: Nested Array Destructuring
Prompt:
写一段 TSL 脚本,从 array((1, 2), (3, 4)) 拆出 r1 和 r2,
并输出 r1[0]、r1[1]、r2[0]、r2[1]。只输出代码。
Pass criteria:
- Uses
[r1, r2] := array((1, 2), (3, 4));. - Reads nested array elements with zero-based indexes.
Source docs:
docs/tsl/syntax/04_variables_and_constants.mddocs/tsl/syntax/12_matrix_and_collections.md
TSL-069: Row Set Operations
Prompt:
写一段 TSL 脚本,对 left_rows 和 right_rows 做 union2、intersect、minus、outersect。
只输出代码。
Pass criteria:
- Uses row-set operators
union2,intersect,minus, andoutersect. - Does not treat
union2as preserving duplicate rows.
Source docs:
docs/tsl/syntax/12_matrix_and_collections.md
TSL-070: filterIn Single Column
Prompt:
写一段 TSL 示例,用 filterIn 按单列从结果集中筛选命中行。
只输出代码。
Pass criteria:
- Uses documented
filterIn(...)shape. - Does not replace resultset filtering with
in/sqlinset operations.
Source docs:
docs/tsl/syntax/13_resultset_and_filters.md
TSL-071: filterNotIn
Prompt:
写一段 TSL 示例,用 filterNotIn 从结果集中排除命中行。
只输出代码。
Pass criteria:
- Uses documented
filterNotIn(...)shape. - Does not use
minuswhen the task asks to preserve filtering semantics.
Source docs:
docs/tsl/syntax/13_resultset_and_filters.md
TSL-072: TS-SQL Minimal Query
Prompt:
写一段 TSL 示例,对 array((1, 2), (3, 4)) 使用 TS-SQL 最小查询骨架。
只输出代码。
Pass criteria:
- Uses documented TS-SQL query form from the syntax docs.
- Does not invent ordinary SQL string execution.
Source docs:
docs/tsl/syntax/14_ts_sql.md
TSL-073: TS-SQL where And order by
Prompt:
写一段 TSL 示例,使用 TS-SQL 对数组结果集按条件过滤并排序。
只输出代码。
Pass criteria:
- Uses documented
whereandorder byTS-SQL syntax. - Does not use SQL
%wildcard assumptions unless documented for TS-SQL.
Source docs:
docs/tsl/syntax/14_ts_sql.md
TSL-074: TS-SQL group by
Prompt:
写一段 TSL 示例,使用 TS-SQL 按字段 group by,并计算每组统计值。
只输出代码。
Pass criteria:
- Uses documented
group byTS-SQL form. - Uses documented aggregate/reference helpers only.
Source docs:
docs/tsl/syntax/14_ts_sql.md
TSL-075: TS-SQL join
Prompt:
写一段 TSL 示例,用 TS-SQL join 两个数组结果集。只输出代码。
Pass criteria:
- Uses documented
joinform. - Does not invent database connection or external SQL execution.
Source docs:
docs/tsl/syntax/14_ts_sql.md
TSL-076: Runtime with Star
Prompt:
写一段 TSL 示例,使用 docs/tsl 中的 with * 块环境写法。
只输出代码。
Pass criteria:
- Uses documented
with *syntax. - Does not invent Python
withsemantics.
Source docs:
docs/tsl/syntax/10_runtime_context_and_with.md
TSL-077: Runtime with Double Star
Prompt:
写一段 TSL 示例,使用 docs/tsl 中的 with ** 块环境写法。
只输出代码。
Pass criteria:
- Uses documented
with **syntax. - Does not generalize beyond the documented runtime context form.
Source docs:
docs/tsl/syntax/10_runtime_context_and_with.md
TSL-078: Grid Call Timeout
Prompt:
写一段 TSL 示例,用 # 网格调用并带 timeout。只输出代码。
Pass criteria:
- Uses documented
#Func(...)andtimeout Nshape. - Does not turn
timeoutinto a normal function argument unless documented.
Source docs:
docs/tsl/syntax/10_runtime_context_and_with.md
TSL-079: Global Cache
Prompt:
写一段 TSL 示例,设置全局缓存、读取全局缓存,并判断缓存是否存在。
只输出代码。
Pass criteria:
- Uses documented
setGlobalCache,getGlobalCache, andifCache. - Does not invent browser/local-storage style APIs.
Source docs:
docs/tsl/syntax/10_runtime_context_and_with.md
TSL-080: Conditional Compilation
Prompt:
写一段 TSL 示例,使用 {$ifdef ...} 和 {$else} 做条件编译分支。
只输出代码。
Pass criteria:
- Uses documented compile-option syntax.
- Does not write runtime
ifwhen the task asks for conditional compilation.
Source docs:
docs/tsl/syntax/16_lexical_structure_and_compile_options.md
TSL-081: Comments And Identifiers
Prompt:
写一段 TSL 示例,包含 docs/tsl 支持的注释写法和一个普通标识符赋值。
只输出代码。
Pass criteria:
- Uses documented comment syntax from the lexical structure page.
- Uses
:=for assignment.
Source docs:
docs/tsl/syntax/16_lexical_structure_and_compile_options.md
TSL-082: goto Label
Prompt:
写一段 TSL 示例,使用 goto 跳转到标签并输出结果。只输出代码。
Pass criteria:
- Uses documented
gotoand label syntax. - Does not invent C-style label rules if they differ from docs.
Source docs:
docs/tsl/syntax/15_debug_and_profiler.md
TSL-083: debugReturn
Prompt:
写一段 TSL 示例,使用 debugReturn 提前返回调试值。只输出代码。
Pass criteria:
- Uses documented
debugReturnform. - Does not confuse it with ordinary
returnunless both are required.
Source docs:
docs/tsl/syntax/15_debug_and_profiler.md
TSL-084: Profiler Timing
Prompt:
写一段 TSL 示例,使用 mtic 和 mtoc 做简单计时。只输出代码。
Pass criteria:
- Uses documented
mtic/mtocshape. - Does not invent external timing APIs.
Source docs:
docs/tsl/syntax/15_debug_and_profiler.md
TSL-085: External Function Declaration
Prompt:
写一个 TSL external 函数声明示例,按 docs/tsl 的最小 external 写法。
只输出代码。
Pass criteria:
- Uses documented
externaldeclaration shape. - Does not invent FFI syntax from C, Python, or TypeScript.
Source docs:
docs/tsl/syntax/18_external_calls_and_threads.md
TSL-086: External Procedure Declaration
Prompt:
写一个 TSL procedure external 示例。只输出代码。
Pass criteria:
- Uses documented
procedure externalshape. - Does not put a return type on the procedure header.
Source docs:
docs/tsl/syntax/18_external_calls_and_threads.md
TSL-087: Native Function Pointer Wrapper
Prompt:
写一段 TSL 示例,按 docs/tsl 包装原生函数指针。只输出代码。
Pass criteria:
- Uses only the documented native-function-pointer wrapper shape.
- Does not invent raw pointer syntax.
Source docs:
docs/tsl/syntax/18_external_calls_and_threads.md
TSL-088: Thread Minimal Pattern
Prompt:
写一段 TSL 线程模式最小正例,按 docs/tsl 的线程示例组织。
只输出代码。
Pass criteria:
- Uses documented thread-mode syntax.
- Does not invent async/await or JavaScript thread syntax.
Source docs:
docs/tsl/syntax/18_external_calls_and_threads.md
TSL-089: Class Property
Prompt:
写一个 TSL 类 Box,字段 value 通过 property Value read/write 访问。
脚本里设置并输出这个属性。只输出代码。
Pass criteria:
- Uses documented
property Name read ... write ...shape. - Uses
type Box = class. - Creates with
new Box().
Source docs:
docs/tsl/syntax/08_objects_and_classes.md
TSL-090: Typed Class Property
Prompt:
写一个 TSL 类 Person,包含 string 类型字段 name_,
并定义带类型注解的 property Name。只输出代码。
Pass criteria:
- Uses field type annotation such as
name_: string;. - Uses documented typed property form.
- Does not invent C# property blocks.
Source docs:
docs/tsl/syntax/08_objects_and_classes.md
TSL-091: Method Overload
Prompt:
写一个 TSL 类 Calc,包含两个同名 Add 方法,参数个数不同。
只输出代码。
Pass criteria:
- Uses documented
overloadmethod form. - Keeps methods inside
type Calc = class.
Source docs:
docs/tsl/syntax/08_objects_and_classes.md
TSL-092: Inheritance
Prompt:
写一个 TSL 类 Animal 和继承它的 Dog,Dog 增加一个方法 Speak。
只输出代码。
Pass criteria:
- Uses
type Dog = class(Animal). - Does not use
extends.
Source docs:
docs/tsl/syntax/08_objects_and_classes.md
TSL-093: Virtual Override
Prompt:
写一个 TSL 父类 Base,虚方法 Name;子类 Child 覆盖 Name。
脚本里创建 Child 并输出 Name。只输出代码。
Pass criteria:
- Uses documented
virtualandoverride. - Uses
type Child = class(Base). - Creates with
new Child().
Source docs:
docs/tsl/syntax/08_objects_and_classes.md
TSL-094: Inherited Method Call
Prompt:
写一个 TSL 子类方法,在方法里调用父类同名方法后再追加自己的逻辑。
只输出代码。
Pass criteria:
- Uses documented
Inheritedcall form. - Does not invent
super.method()syntax.
Source docs:
docs/tsl/syntax/08_objects_and_classes.md
TSL-095: Class Method Implementation Outside Class
Prompt:
写一个 TSL 类 Greeter,类内只声明 Say 方法,
在类外用 ClassName.Method 形式实现它。只输出代码。
Pass criteria:
- Uses class declaration plus
function Greeter.Say(...)implementation. - Does not append executable script statements after the implementation section.
Source docs:
docs/tsl/syntax/08_objects_and_classes.md
TSL-096: createObject By String Class Name
Prompt:
写一段 TSL 示例,用字符串类名通过 createObject 创建本地类实例。
只输出代码。
Pass criteria:
- Uses documented
createObject("ClassName")shape. - Uses
new ClassName()only if explaining it is not the requested string-name path.
Source docs:
docs/tsl/syntax/08_objects_and_classes.md
TSL-097: Destructor
Prompt:
写一个 TSL 类,定义无参 destroy 函数,在对象引用设为 nil 时触发清理。
只输出代码。
Pass criteria:
- Uses
function destroy();. - Sets the object reference to
nilin executable script code. - Does not invent
destructorkeyword.
Source docs:
docs/tsl/syntax/08_objects_and_classes.md
TSL-098: FMArray Basics
Prompt:
写一段 TSL 示例,创建 FMArray,判断它是 FMArray,并输出尺寸信息。
只输出代码。
Pass criteria:
- Uses documented FMArray construction from the FMArray page.
- Uses documented FMArray type/size helpers.
- Does not treat plain
array(...)as automatically being FMArray.
Source docs:
docs/tsl/syntax/23_fmarray.md
TSL-099: Matrix Deep Dive
Prompt:
写一段 TSL 示例,初始化矩阵并使用 mrows、mcols、msize 输出维度。
只输出代码。
Pass criteria:
- Uses documented matrix initialization.
- Uses
mrows,mcols, andmsize.
Source docs:
docs/tsl/syntax/22_matrix_deep_dive.md
TSL-100: Object Operator Overload
Prompt:
写一个 TSL 类,重载二元 + 运算符,让两个对象相加得到一个新对象。
只输出代码。
Pass criteria:
- Uses documented
operator +overload shape. - Keeps overload implementation inside a valid
type Name = classstructure. - Does not invent Python
__add__or C++ syntax.
Source docs:
docs/tsl/syntax/24_object_overloads_and_iteration.md
Result Sheet Template
Copy this table for each evaluated agent:
| Case | Score | Failure pattern | Notes |
|---|---|---|---|
| TSL-001 | |||
| TSL-002 | |||
| TSL-003 | |||
| TSL-004 | |||
| TSL-005 | |||
| TSL-006 | |||
| TSL-007 | |||
| TSL-008 | |||
| TSL-009 | |||
| TSL-010 | |||
| TSL-011 | |||
| TSL-012 | |||
| TSL-013 | |||
| TSL-014 | |||
| TSL-015 | |||
| TSL-016 | |||
| TSL-017 | |||
| TSL-018 | |||
| TSL-019 | |||
| TSL-020 | |||
| TSL-021 | |||
| TSL-022 | |||
| TSL-023 | |||
| TSL-024 | |||
| TSL-025 | |||
| TSL-026 | |||
| TSL-027 | |||
| TSL-028 | |||
| TSL-029 | |||
| TSL-030 | |||
| TSL-031 | |||
| TSL-032 | |||
| TSL-033 | |||
| TSL-034 | |||
| TSL-035 | |||
| TSL-036 | |||
| TSL-037 | |||
| TSL-038 | |||
| TSL-039 | |||
| TSL-040 | |||
| TSL-041 | |||
| TSL-042 | |||
| TSL-043 | |||
| TSL-044 | |||
| TSL-045 | |||
| TSL-046 | |||
| TSL-047 | |||
| TSL-048 | |||
| TSL-049 | |||
| TSL-050 | |||
| TSL-051 | |||
| TSL-052 | |||
| TSL-053 | |||
| TSL-054 | |||
| TSL-055 | |||
| TSL-056 | |||
| TSL-057 | |||
| TSL-058 | |||
| TSL-059 | |||
| TSL-060 | |||
| TSL-061 | |||
| TSL-062 | |||
| TSL-063 | |||
| TSL-064 | |||
| TSL-065 | |||
| TSL-066 | |||
| TSL-067 | |||
| TSL-068 | |||
| TSL-069 | |||
| TSL-070 | |||
| TSL-071 | |||
| TSL-072 | |||
| TSL-073 | |||
| TSL-074 | |||
| TSL-075 | |||
| TSL-076 | |||
| TSL-077 | |||
| TSL-078 | |||
| TSL-079 | |||
| TSL-080 | |||
| TSL-081 | |||
| TSL-082 | |||
| TSL-083 | |||
| TSL-084 | |||
| TSL-085 | |||
| TSL-086 | |||
| TSL-087 | |||
| TSL-088 | |||
| TSL-089 | |||
| TSL-090 | |||
| TSL-091 | |||
| TSL-092 | |||
| TSL-093 | |||
| TSL-094 | |||
| TSL-095 | |||
| TSL-096 | |||
| TSL-097 | |||
| TSL-098 | |||
| TSL-099 | |||
| TSL-100 |