69 KiB
TSL Agent 代码生成提示测试
本文件定义了用于评估 agent 能否阅读 docs/tsl 并在首次尝试时生成语法正确的 TSL 代码的手动提示测试。
这些不是 TSL 语言文档。它们是 agent 评估提示。语法事实保留在 docs/tsl 中;agent 测试提示保留在此处。
运行方法
对于每个测试用例:
- 从可访问此仓库的全新 agent 上下文开始。
- 仅将
Prompt文本发送给 agent,除非测试运行器有标准系统提示。 - 允许 agent 阅读
docs/tsl。 - 仅对第一个完整答案评分。不允许 agent 修订。
- 根据
Pass criteria记录通过/失败。
推荐的运行器设置:
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.
评分标准
2= 首次回答满足所有通过标准。1= 基本正确,但有一个不影响被测语法点的小问题。0= 错误的文件模型、无效的 TSL 语法、虚构的语法或遗漏了被测语法点。
跟踪这些汇总指标:
- 整体首次通过准确率。
- 按主题组的准确率。
- 最常见的失败模式。
- 失败是否来自未阅读文档、阅读了错误的文档页面或过度拟合到另一种语言。
全局失败模式
只要生成的代码中出现以下情况,就标记为失败:
- 使用
=进行普通赋值而不是:=。 - 在类型化参数列表中使用逗号分隔符,例如
function Add(a: integer, b: integer): integer。 - 将命名参数写为
a = 1而不是a: 1。 - 将
.tsl脚本写为仅包含顶层可复用声明,而请求的是可执行脚本行为。 - 在
.tslfunction 或 class 声明部分之后追加可执行脚本语句。 - 将顶层 class 写为
class Name ... end;而不是type Name = class ... end;。 - 对 class function 或 static 字段使用裸类名而不是
class(Name)。 - 虚构
docs/tsl中未记录的语法。
测试用例
TSL-001: 类型化加法函数
Prompt:
请根据本仓库 docs/tsl 的语法,写一个 TSL 加法函数 Add。
要求两个参数都有整数类型,返回值也要有整数类型。
只输出代码。
Expected focus:
- 基本的
function声明。 - 类型化参数和类型化返回值。
Pass criteria:
- 使用
function Add(a: integer; b: integer): integer;。 - 使用
return a + b;。 - 使用
begin ... end;。 - 不用逗号分隔类型化参数。
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-002: 调用本地函数的可执行脚本
Prompt:
写一段可执行的 .tsl 脚本:计算 1 + 2,并用 writeLn 输出结果。
加法逻辑封装成 Add 函数,脚本里调用它。
只输出代码。
Expected focus:
.tsl文件模型。- 可执行语句在本地函数声明之前。
Pass criteria:
- 脚本语句出现在
function Add...声明之前。 - 在声明之前调用
writeLn(Add(1, 2));或等效语句。 - 不在函数声明之后追加可执行语句。
- 如果引入赋值,使用
:=进行普通赋值。
Source docs:
docs/tsl/syntax/01_quickstart.mddocs/tsl/syntax/02_core_model.mddocs/tsl/syntax/05_functions_and_calls.md
TSL-003: 可复用函数文件
Prompt:
我要一个可复用的 .tsf 函数扩展文件,里面只有一个函数 IsPositive,
输入整数 x,返回 x 是否大于 0。只输出代码。
Expected focus:
.tsf可复用声明模型。- 没有可执行脚本入口语句。
Pass criteria:
- 输出顶层
function IsPositive(x: integer);或类型化返回值变体(如果所选证据支持)。 - 函数体返回
x > 0。 - 不添加
.tsl入口语句,如writeLn(...)。 - 不虚构未记录的
boolean返回类型。
Source docs:
docs/tsl/syntax/01_quickstart.mddocs/tsl/syntax/02_core_model.mddocs/tsl/syntax/05_functions_and_calls.md
TSL-004: 带写回参数的过程
Prompt:
写一段 .tsl 脚本,定义一个过程 Bump,把传入变量加 1。
脚本里先把 a 设为 1,调用 Bump(a),再输出 a。只输出代码。
Expected focus:
- 仅在显式请求时使用
procedure。 var参数写回。.tsl声明部分顺序。
Pass criteria:
- 使用
procedure Bump(var x);。 - 在调用
Bump(a);之前赋值a := 1;。 - 在 procedure 声明之前输出
a。 - 不在
procedure头上加返回类型。
Source docs:
docs/tsl/syntax/05_functions_and_calls.mddocs/tsl/syntax/02_core_model.md
TSL-005: 命名参数调用
Prompt:
写一个 TSL 示例,定义函数 MakePair(a, b),返回 array(a, b)。
调用时必须使用命名参数,把 b 传 20,把 a 传 10,并输出两个元素。
只输出代码。
Expected focus:
- 命名参数语法。
- Array 索引。
Pass criteria:
- 使用
MakePair(b: 20, a: 10)或等效的命名参数顺序调用函数。 - 不使用
MakePair(b = 20, a = 10)。 - 使用从零开始的 array 索引读取数组元素。
- 在
.tsl中保持可执行语句在函数声明之前。
Source docs:
docs/tsl/syntax/05_functions_and_calls.mddocs/tsl/syntax/12_matrix_and_collections.md
TSL-006: 默认变量模型
Prompt:
写一段最简单的 TSL 脚本:把 3 赋给 a,把 4 赋给 b,
再输出 a * b。不要做多余声明。只输出代码。
Expected focus:
- 普通变量默认不需要
var声明。 - 赋值运算符。
Pass criteria:
- 使用
a := 3;和b := 4;。 - 不使用
a = 3;或b = 4;。 - 不添加不必要的
var声明。
Source docs:
docs/tsl/syntax/04_variables_and_constants.mddocs/tsl/syntax/06_expressions_and_operators.md
TSL-007: 显式变量模式
Prompt:
写一段 TSL 脚本,开启 explicit 模式,声明变量 total,
把 total 设置为 0,然后输出它。只输出代码。
Expected focus:
{$explicit+}。- 显式
var声明。
Pass criteria:
- 以
{$explicit+}开头或在首次使用未声明变量之前放置。 - 声明
var total;。 - 使用
total := 0;赋值。
Source docs:
docs/tsl/syntax/04_variables_and_constants.mddocs/tsl/syntax/16_lexical_structure_and_compile_options.md
TSL-008: 常量初始化
Prompt:
写一段 TSL 脚本,定义常量 max_count 为 3 + 4,
然后输出 max_count。只输出代码。
Expected focus:
const name = value;是常量初始化,不是普通赋值。
Pass criteria:
- 使用
const max_count = 3 + 4;。 - 输出
max_count。 - 之后不对
max_count赋值。
Source docs:
docs/tsl/syntax/04_variables_and_constants.mddocs/tsl/syntax/06_expressions_and_operators.md
TSL-009: 单变量解构
Prompt:
写一段 TSL 脚本,从 array(7, 8, 9) 里只拆出第一个值到 first,
然后输出 first。只输出代码。
Expected focus:
- 单变量解构保留尾随逗号。
Pass criteria:
- 使用
[first, ] := array(7, 8, 9);。 - 不使用
[first] := ...。
Source docs:
docs/tsl/syntax/04_variables_and_constants.mddocs/tsl/syntax/06_expressions_and_operators.md
TSL-010: If Else 块
Prompt:
写一段 TSL 脚本:如果 score >= 60,就把 result 设为 "pass",
否则设为 "fail",最后输出 result。score 设为 70。只输出代码。
Expected focus:
- 块式
if ... then begin ... end else begin ... end。 then块的end和else之间没有分号。
Pass criteria:
- 使用
if score >= 60 then后跟有效块。 - 不在
then分支的end之后、else之前放置分号。 - 在条件块之后输出,不是仅在一个分支内输出。
Source docs:
docs/tsl/syntax/07_control_flow.md
TSL-011: 带步长的 For 循环
Prompt:
写一段 TSL 脚本,用 for 循环计算 1、3、5 的和并输出。
要求使用 step。只输出代码。
Expected focus:
for i := 1 to 5 step 2 do。
Pass criteria:
- 使用
for i := 1 to 5 step 2 do。 - 使用
:=或+=累加。 - 输出
9或计算的和变量。
Source docs:
docs/tsl/syntax/07_control_flow.md
TSL-012: Array 遍历
Prompt:
写一段 TSL 脚本,遍历 array(10, 20, 30),每行输出索引和值的和。
必须使用 for i, v in data。只输出代码。
Expected focus:
- Array 遍历形式。
- 从零开始的索引行为。
Pass criteria:
- 使用
for i, v in data do。 - 使用
data := array(10, 20, 30);。 - 不虚构 Python 风格或 JavaScript 风格的迭代语法。
Source docs:
docs/tsl/syntax/07_control_flow.md
TSL-013: Array 和 String 索引
Prompt:
写一段 TSL 脚本,创建 array(10, 20, 30) 和字符串 "ABC"。
输出数组第一个元素,再输出字符串第一个字符。只输出代码。
Expected focus:
- Array 是从零开始的。
- String 是从一开始的。
Pass criteria:
- 使用
arr[0]读取第一个数组元素。 - 使用
s[1]读取第一个字符串字符。 - 不使用
s[0]。
Source docs:
docs/tsl/syntax/01_quickstart.mddocs/tsl/syntax/03_values_and_literals.mddocs/tsl/syntax/11_pitfalls.md
TSL-014: 类哈希 Array
Prompt:
写一段 TSL 脚本,用 array 创建一个带字符串键的表,
包含 Code = "0001" 和 Price = 12.3,然后输出 Code。只输出代码。
Expected focus:
array("Code": "0001", "Price": 12.3)。
Pass criteria:
- 使用字符串键
array(...)语法。 - 使用
hash["Code"]或等效变量名读取。
Source docs:
docs/tsl/syntax/12_matrix_and_collections.md
TSL-015: in 与 sqlin
Prompt:
写一段 TSL 脚本,同时演示:
1 是否属于 array(1, 2),以及 array(1, 2) 这一整行是否存在于
array((1, 2), (3, 4))。分别输出两个判断结果。只输出代码。
Expected focus:
- 元素/子集关系使用
in。 - 整行关系使用
sqlin。
Pass criteria:
- 使用
1 in array(1, 2)。 - 使用
array(1, 2) sqlin array((1, 2), (3, 4))。 - 不对整行测试使用
in。
Source docs:
docs/tsl/syntax/12_matrix_and_collections.md
TSL-016: 显式字符串到整数转换
Prompt:
写一段 TSL 脚本,把字符串 "1234" 转成整数后加 1,
再输出结果。只输出代码。
Expected focus:
- 显式转换而不是依赖混合类型算术。
Pass criteria:
- 使用
strToInt(...)。 - 不直接计算
"1234" + 1。
Source docs:
docs/tsl/syntax/17_types_and_conversions.md
TSL-017: Nil 处理
Prompt:
写一段 TSL 脚本,创建空数组 arr,判断 arr[0] 是否为 nil,
并输出判断结果。只输出代码。
Expected focus:
- 空数组缺失元素返回
nil。 - 显式 nil 比较。
Pass criteria:
- 使用
arr := array();。 - 检查
arr[0] = nil或使用已记录的ifNil(...)。 - 不虚构
null、None或undefined。
Source docs:
docs/tsl/syntax/17_types_and_conversions.md
TSL-018: 类正则表达式 Like
Prompt:
写一段 TSL 脚本,判断字符串 "abc" 是否匹配以 a 开头的模式,
用 like 运算符,并输出结果。只输出代码。
Expected focus:
like右侧是类正则表达式,不是 SQL%通配符。
Pass criteria:
- 使用正则风格模式,如
"^a.*"或其他已记录的兼容正则模式。 - 不使用
"a%"作为模式。
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-041: 位运算符
Prompt:
写一段 TSL 脚本,对两个整数演示位与、位或、位非、位异或,
并输出结果。只输出代码。
Pass criteria:
- 使用点前缀位运算符,如
.&、.|、.!和.^。 - 不使用普通的
&、|或~作为位运算符。
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-042: 复合赋值和自增
Prompt:
写一段 TSL 脚本,a 初始为 1,先用复合赋值加 2,
再自增一次,最后输出 a。只输出代码。
Pass criteria:
- 使用已记录的
+=和a++或++a。 - 使用
a := 1;初始化。 - 不使用
a = a + 2。
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-043: Nil 安全访问
Prompt:
写一段 TSL 示例,安全读取可能为 nil 的对象成员 value,
使用 docs/tsl 里的空安全访问写法。只输出代码。
Pass criteria:
- 使用已记录的 nil 安全访问,如
obj?.value。 - 不虚构超出已记录模式的可选链式调用形式。
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-044: 标量链式比较
Prompt:
写一段 TSL 脚本,判断 1 < 2 < 3 的连续标量比较并输出结果。
使用 docs/tsl 的链式比较写法。只输出代码。
Pass criteria:
- 使用标量链式比较,如
1 :< 2 :< 3。 - 不写 Python 风格的
1 < 2 < 3。
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-045: 类矩阵链式比较
Prompt:
写一段 TSL 脚本,对 array(1, 2, -1)、array(2, 1, 0)、array(3, 2, 1)
做逐元素链式小于比较,并输出结果数组的三个元素。只输出代码。
Pass criteria:
- 使用矩阵链式比较,如
::<。 - 使用从零开始的索引读取结果数组元素。
- 不对数组级比较使用标量
:<。
Source docs:
docs/tsl/syntax/12_matrix_and_collections.mddocs/tsl/syntax/06_expressions_and_operators.md
TSL-046: 默认参数
Prompt:
写一个 TSL 函数 AddOne,参数 a 默认值为 1,返回 a + 1。
再写脚本输出 AddOne() 和 AddOne(5)。只输出代码。
Pass criteria:
- 使用
function AddOne(a = 1);。 - 在
.tsl声明部分之前调用函数。 - 不使用不支持的默认参数语法。
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-047: 类型化默认参数
Prompt:
写一个 TSL 函数 TypedAdd,参数 a 是 integer,默认值为 1,
返回值是 integer,返回 a + 1。只输出代码。
Pass criteria:
- 使用
function TypedAdd(a: integer = 1): integer;。 - 不用逗号分隔类型化参数。
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-048: 跳过中间参数的命名参数
Prompt:
写一段 TSL 脚本,定义 TestFunc(a, b, c),调用 TestFunc(1, c: 3),
在函数里输出 b 是否为 nil。只输出代码。
Pass criteria:
- 使用命名参数语法
c: 3。 - 使用
ifNil(b)或已记录的 nil 比较检查跳过的b。 - 保持可执行调用在函数声明之前。
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-049: 带命名参数的 call
Prompt:
写一段 TSL 脚本,通过 call 调用 TestFunc,并用命名参数传 a、b、c。
TestFunc 返回 a * 100 + b * 10 + c。只输出代码。
Pass criteria:
- 使用
call("TestFunc", a: ..., b: ..., c: ...)。 - 不用
=写命名参数。 - 在
.tsl中的调用之后定义TestFunc。
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-050: varByRef 开关
Prompt:
写一段 TSL 脚本,演示 {$varByRef-} 下未修饰参数不写回,
但 var 参数仍会写回。只输出代码。
Pass criteria:
- 使用
{$varByRef-},如果需要则稍后使用{$varByRef+}恢复。 - 包含一个未修饰参数函数和一个
var参数函数。 - 不依赖其他语言的值/引用模型。
Source docs:
docs/tsl/syntax/05_functions_and_calls.mddocs/tsl/syntax/16_lexical_structure_and_compile_options.mddocs/tsl/syntax/11_pitfalls.md
TSL-019: 基本 Class
Prompt:
写一段 .tsl 脚本,定义 Person 类,包含 public 字段 name。
脚本里创建 Person,把 name 设为 "Tom",然后输出 name。只输出代码。
Expected focus:
- 顶层 class 声明语法。
.tsl可执行语句在 class 声明部分之前。
Pass criteria:
- 使用
type Person = class。 - 在
name;之前包含public。 - 使用
new Person()创建。 - 不写
class Person。 - 不在 class 声明之后追加可执行语句。
Source docs:
docs/tsl/syntax/08_objects_and_classes.mddocs/tsl/syntax/02_core_model.md
TSL-020: Public 构造函数
Prompt:
写一段 .tsl 脚本,定义 Counter 类。
构造函数接收初始值 v,保存到 value;Inc 方法把 value 加 1 并返回。
脚本里 new Counter(10),输出 Inc 的结果。只输出代码。
Expected focus:
public下的function create(...)构造函数。- 实例方法体直接访问成员。
Pass criteria:
- 定义
type Counter = class。 - 在
public部分放置function create(v);。 - 在
create中使用value := v;。 - 在
Inc中使用value := value + 1; return value;或等效语句。 - 不将
create设为 private 或 protected。
Source docs:
docs/tsl/syntax/08_objects_and_classes.md
TSL-021: Static 字段访问
Prompt:
写一段 TSL 示例,定义 THuman 类,包含 static 字段 mCount。
先把 mCount 设置为 100,再输出它。只输出代码。
Expected focus:
- 通过 class type 访问 static 字段。
Pass criteria:
- 定义
static mCount;。 - 通过
class(THuman).mCount设置或读取。 - 不使用
THuman.mCount。
Source docs:
docs/tsl/syntax/08_objects_and_classes.mddocs/tsl/syntax/11_pitfalls.md
TSL-022: Class Function 访问
Prompt:
写一个 TSL 类 MathBox,里面有 class function Add(a, b),返回 a + b。
再写脚本输出 MathBox 的 Add(1, 2) 结果。只输出代码。
Expected focus:
- Class function 声明。
- 通过 class type 调用 class function。
Pass criteria:
- 在
type MathBox = class内定义class function Add(a, b);。 - 通过
class(MathBox).Add(1, 2)或其他已记录的 class-type 路径调用。 - 不调用
MathBox.Add(1, 2)。 - 在
.tsl中保持可执行调用在 class 声明之前。
Source docs:
docs/tsl/syntax/08_objects_and_classes.mddocs/tsl/syntax/11_pitfalls.md
TSL-023: 完整 Unit 骨架
Prompt:
写一个 .tsf unit,名字是 DemoUnit。
对外暴露函数 Ping,调用返回 1。使用完整 interface / implementation 结构。
只输出代码。
Expected focus:
- 完整的
unit结构。 end.终止符。
Pass criteria:
- 以
unit DemoUnit;开头。 - 有
interface和implementation部分。 - 在
interface中声明function Ping();。 - 实现
function Ping(); begin return 1; end;。 - 以
end.结束 unit。
Source docs:
docs/tsl/syntax/09_units_and_scope.mddocs/tsl/syntax/01_quickstart.md
TSL-024: 顶层 uses 在语句之前
Prompt:
写一段 .tsl 脚本,使用 UnitA 和 UnitB 两个 unit,
然后调用 Run() 并输出结果。注意 uses 的位置。只输出代码。
Expected focus:
- 顶层
uses在普通语句之前。 - 一个
uses语句中包含多个 unit。
Pass criteria:
- 在可执行语句之前使用
uses UnitA, UnitB;。 - 不在顶层
uses之前写普通语句。 - 默认不生成两个独立的顶层
uses语句。
Source docs:
docs/tsl/syntax/09_units_and_scope.mddocs/tsl/syntax/11_pitfalls.md
TSL-025: 函数体 uses 位置
Prompt:
写一个 TSL 函数 RunInFunction,函数体内使用 DemoUnit,
然后返回 Ping()。只输出这个函数代码。
Expected focus:
- 函数体
uses必须是第一条语句。
Pass criteria:
- 将
uses DemoUnit;作为begin之后的第一条语句。 - 不在函数体
uses之前放置任何赋值或其他语句。 - 不在同一个函数体内重复
uses。
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 异常语法。
exceptObject字段。
Pass criteria:
- 使用
try ... except ... end。 - 使用
raise "bad"抛出。 - 在
except块中读取exceptObject.errInfo。
Source docs:
docs/tsl/syntax/07_control_flow.md
TSL-027: 模糊的文件模型
Prompt:
帮我写一个 TSL 的加法函数。
Expected focus:
- 处理未充分指定的用户请求。
- 避免虚构文件模型假设。
Pass criteria:
- 要么仅生成最小的可复用函数声明,要么在代码之前明确说明文件模型假设。
- 使用
function,不使用procedure。 - 不生成无效的
.tsl声明排序。 - 如果提示未要求参数类型,则不虚构参数类型。
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: 带类型要求的不规范提示
Prompt:
帮我写一个tsl代码,写一个加法,需要参数类型和返回类型。
Expected focus:
- 对非正式中文提示的鲁棒性。
- 正确的类型化函数语法。
Pass criteria:
- 使用带类型化参数和类型化返回值的
function。 - 在类型化参数之间使用分号。
- 使用
return a + b;。 - 不使用类似 TypeScript 的语法,如
function add(a: number, b: number): number。
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-029: 反 Pascal 赋值陷阱
Prompt:
写一段 TSL 脚本,把 a 设为 1,把 b 设为 2,
如果 a + b 等于 3 就输出 "ok"。只输出代码。
Expected focus:
- 普通赋值与相等比较。
Pass criteria:
- 使用
a := 1;和b := 2;。 - 仅在比较表达式中使用
=。 - 不使用
==。
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-041: 位运算符
Prompt:
写一段 TSL 脚本,对两个整数演示位与、位或、位非、位异或,
并输出结果。只输出代码。
Pass criteria:
- 使用点前缀位运算符,如
.&、.|、.!和.^。 - 不使用普通的
&、|或~作为位运算符。
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-042: 复合赋值和自增
Prompt:
写一段 TSL 脚本,a 初始为 1,先用复合赋值加 2,
再自增一次,最后输出 a。只输出代码。
Pass criteria:
- 使用已记录的
+=和a++或++a。 - 使用
a := 1;初始化。 - 不使用
a = a + 2。
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-043: Nil 安全访问
Prompt:
写一段 TSL 示例,安全读取可能为 nil 的对象成员 value,
使用 docs/tsl 里的空安全访问写法。只输出代码。
Pass criteria:
- 使用已记录的 nil 安全访问,如
obj?.value。 - 不虚构超出已记录模式的可选链式调用形式。
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-044: 标量链式比较
Prompt:
写一段 TSL 脚本,判断 1 < 2 < 3 的连续标量比较并输出结果。
使用 docs/tsl 的链式比较写法。只输出代码。
Pass criteria:
- 使用标量链式比较,如
1 :< 2 :< 3。 - 不写 Python 风格的
1 < 2 < 3。
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-045: 类矩阵链式比较
Prompt:
写一段 TSL 脚本,对 array(1, 2, -1)、array(2, 1, 0)、array(3, 2, 1)
做逐元素链式小于比较,并输出结果数组的三个元素。只输出代码。
Pass criteria:
- 使用矩阵链式比较,如
::<。 - 使用从零开始的索引读取结果数组元素。
- 不对数组级比较使用标量
:<。
Source docs:
docs/tsl/syntax/12_matrix_and_collections.mddocs/tsl/syntax/06_expressions_and_operators.md
TSL-046: 默认参数
Prompt:
写一个 TSL 函数 AddOne,参数 a 默认值为 1,返回 a + 1。
再写脚本输出 AddOne() 和 AddOne(5)。只输出代码。
Pass criteria:
- 使用
function AddOne(a = 1);。 - 在
.tsl声明部分之前调用函数。 - 不使用不支持的默认参数语法。
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-047: 类型化默认参数
Prompt:
写一个 TSL 函数 TypedAdd,参数 a 是 integer,默认值为 1,
返回值是 integer,返回 a + 1。只输出代码。
Pass criteria:
- 使用
function TypedAdd(a: integer = 1): integer;。 - 不用逗号分隔类型化参数。
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-048: 跳过中间参数的命名参数
Prompt:
写一段 TSL 脚本,定义 TestFunc(a, b, c),调用 TestFunc(1, c: 3),
在函数里输出 b 是否为 nil。只输出代码。
Pass criteria:
- 使用命名参数语法
c: 3。 - 使用
ifNil(b)或已记录的 nil 比较检查跳过的b。 - 保持可执行调用在函数声明之前。
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-049: 带命名参数的 call
Prompt:
写一段 TSL 脚本,通过 call 调用 TestFunc,并用命名参数传 a、b、c。
TestFunc 返回 a * 100 + b * 10 + c。只输出代码。
Pass criteria:
- 使用
call("TestFunc", a: ..., b: ..., c: ...)。 - 不用
=写命名参数。 - 在
.tsl中的调用之后定义TestFunc。
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-050: varByRef 开关
Prompt:
写一段 TSL 脚本,演示 {$varByRef-} 下未修饰参数不写回,
但 var 参数仍会写回。只输出代码。
Pass criteria:
- 使用
{$varByRef-},如果需要则稍后使用{$varByRef+}恢复。 - 包含一个未修饰参数函数和一个
var参数函数。 - 不依赖其他语言的值/引用模型。
Source docs:
docs/tsl/syntax/05_functions_and_calls.mddocs/tsl/syntax/16_lexical_structure_and_compile_options.mddocs/tsl/syntax/11_pitfalls.md
TSL-030: 声明后无脚本陷阱
Prompt:
写一段 .tsl 脚本:先调用 Hello(),Hello 输出 "hello"。
调用完成后再输出 "done"。只输出代码。
Expected focus:
- 所有可执行脚本语句必须在声明部分之前。
- 自然的提示顺序可能诱使 agent 在
function Hello之后放置writeLn("done")。
Pass criteria:
- 将
Hello();和输出"done"的语句都放在function Hello();之前。 - 在可执行语句之后定义
Hello。 - 不在函数声明之后追加
"done"输出语句。
Source docs:
docs/tsl/syntax/01_quickstart.mddocs/tsl/syntax/02_core_model.mddocs/tsl/syntax/11_pitfalls.md
扩展紧凑用例
前 30 个用例是详细的基线用例。以下紧凑用例扩展了语法覆盖范围,同时保持每个提示独立可运行。
TSL-031: 数字字面量类型
Prompt:
写一段 TSL 脚本,分别输出 0x10、0b10、0o10、100L、1E2 的类型判断结果。
只输出代码。
Pass criteria:
- 使用已记录的数字字面量。
- 使用类型检查,如
ifInt、ifInt64和ifReal。 - 不将字面量重写为仅十进制值。
Source docs:
docs/tsl/syntax/17_types_and_conversions.md
TSL-032: 日期时间字面量
Prompt:
写一段 TSL 脚本,创建 20111231T 和 20101231.0931T,
并分别输出日期和时间字符串。只输出代码。
Pass criteria:
- 使用已记录的日期时间字面量形式。
- 使用已记录的转换辅助函数,如
dateToStr和timeToStr。 - 不虚构 ISO 字符串字面量语法。
Source docs:
docs/tsl/syntax/17_types_and_conversions.md
TSL-033: Boolean 和数字真值性
Prompt:
写一段 TSL 脚本,输出 true、false,并演示 if 2、if 0、if -1 的判断结果。
只输出代码。
Pass criteria:
- 直接使用
true和false。 - 将
0视为 false,将非零数值视为 true。 - 不虚构
True/False大写形式。
Source docs:
docs/tsl/syntax/17_types_and_conversions.md
TSL-034: Nil 算术边界
Prompt:
写一段 TSL 脚本,输出 ifNil(nil)、nil + 1、1 + nil,
以及 nil + nil 是否仍为 nil。只输出代码。
Pass criteria:
- 使用
nil,不使用null、None或undefined。 - 使用
ifNil(nil)或已记录的nil比较。 - 不将
nil + 1拒绝为无效语法。
Source docs:
docs/tsl/syntax/17_types_and_conversions.md
TSL-035: 复数基础
Prompt:
写一段 TSL 脚本,创建复数 4 + 3j 和 complex(5, -2),
输出第一个复数的 real、imag 和 ifComplex 判断。只输出代码。
Pass criteria:
- 按文档使用
4 + 3j或complex(real, imag)。 - 使用
real(...)、imag(...)和ifComplex(...)。 - 不虚构 Python 对象方法,如
.real。
Source docs:
docs/tsl/syntax/17_types_and_conversions.md
TSL-036: 字符串连接
Prompt:
写一段 TSL 脚本,把 "TS" 和 "L" 拼成 "TSL" 并输出。
使用 docs/tsl 里确认的字符串连接写法。只输出代码。
Pass criteria:
- 使用已记录的字符串连接,用
+或$。 - 使用 TSL 字符串字面量。
- 不调用未记录的辅助函数,如
concat(...)。
Source docs:
docs/tsl/syntax/03_values_and_literals.mddocs/tsl/syntax/06_expressions_and_operators.md
TSL-037: 算术运算符覆盖
Prompt:
写一段 TSL 脚本,分别输出 9 div 4、9 mod 4、2 ^ 3、8 ~ 2、3 \ 2。
只输出代码。
Pass criteria:
- 按文档使用
div、mod、^、~和\。 - 不用 JavaScript 风格的运算符替换它们。
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-041: 位运算符
Prompt:
写一段 TSL 脚本,对两个整数演示位与、位或、位非、位异或,
并输出结果。只输出代码。
Pass criteria:
- 使用点前缀位运算符,如
.&、.|、.!和.^。 - 不使用普通的
&、|或~作为位运算符。
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-042: 复合赋值和自增
Prompt:
写一段 TSL 脚本,a 初始为 1,先用复合赋值加 2,
再自增一次,最后输出 a。只输出代码。
Pass criteria:
- 使用已记录的
+=和a++或++a。 - 使用
a := 1;初始化。 - 不使用
a = a + 2。
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-043: Nil 安全访问
Prompt:
写一段 TSL 示例,安全读取可能为 nil 的对象成员 value,
使用 docs/tsl 里的空安全访问写法。只输出代码。
Pass criteria:
- 使用已记录的 nil 安全访问,如
obj?.value。 - 不虚构超出已记录模式的可选链式调用形式。
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-044: 标量链式比较
Prompt:
写一段 TSL 脚本,判断 1 < 2 < 3 的连续标量比较并输出结果。
使用 docs/tsl 的链式比较写法。只输出代码。
Pass criteria:
- 使用标量链式比较,如
1 :< 2 :< 3。 - 不写 Python 风格的
1 < 2 < 3。
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-045: 类矩阵链式比较
Prompt:
写一段 TSL 脚本,对 array(1, 2, -1)、array(2, 1, 0)、array(3, 2, 1)
做逐元素链式小于比较,并输出结果数组的三个元素。只输出代码。
Pass criteria:
- 使用矩阵链式比较,如
::<。 - 使用从零开始的索引读取结果数组元素。
- 不对数组级比较使用标量
:<。
Source docs:
docs/tsl/syntax/12_matrix_and_collections.mddocs/tsl/syntax/06_expressions_and_operators.md
TSL-046: 默认参数
Prompt:
写一个 TSL 函数 AddOne,参数 a 默认值为 1,返回 a + 1。
再写脚本输出 AddOne() 和 AddOne(5)。只输出代码。
Pass criteria:
- 使用
function AddOne(a = 1);。 - 在
.tsl声明部分之前调用函数。 - 不使用不支持的默认参数语法。
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-047: 类型化默认参数
Prompt:
写一个 TSL 函数 TypedAdd,参数 a 是 integer,默认值为 1,
返回值是 integer,返回 a + 1。只输出代码。
Pass criteria:
- 使用
function TypedAdd(a: integer = 1): integer;。 - 不用逗号分隔类型化参数。
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-048: 跳过中间参数的命名参数
Prompt:
写一段 TSL 脚本,定义 TestFunc(a, b, c),调用 TestFunc(1, c: 3),
在函数里输出 b 是否为 nil。只输出代码。
Pass criteria:
- 使用命名参数语法
c: 3。 - 使用
ifNil(b)或已记录的 nil 比较检查跳过的b。 - 保持可执行调用在函数声明之前。
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-049: 带命名参数的 call
Prompt:
写一段 TSL 脚本,通过 call 调用 TestFunc,并用命名参数传 a、b、c。
TestFunc 返回 a * 100 + b * 10 + c。只输出代码。
Pass criteria:
- 使用
call("TestFunc", a: ..., b: ..., c: ...)。 - 不用
=写命名参数。 - 在
.tsl中的调用之后定义TestFunc。
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-050: varByRef 开关
Prompt:
写一段 TSL 脚本,演示 {$varByRef-} 下未修饰参数不写回,
但 var 参数仍会写回。只输出代码。
Pass criteria:
- 使用
{$varByRef-},如果需要则稍后使用{$varByRef+}恢复。 - 包含一个未修饰参数函数和一个
var参数函数。 - 不依赖其他语言的值/引用模型。
Source docs:
docs/tsl/syntax/05_functions_and_calls.mddocs/tsl/syntax/16_lexical_structure_and_compile_options.md
TSL-038: 条件表达式
Prompt:
写一段 TSL 脚本,a 小于 b 时 value 为 10,否则为 20,
要求使用条件表达式并输出 value。只输出代码。
Pass criteria:
- 使用
condition ? true_value : false_value。 - 使用
:=进行赋值。 - 不错误地虚构 C/JS 的
?:位置。
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-041: 位运算符
Prompt:
写一段 TSL 脚本,对两个整数演示位与、位或、位非、位异或,
并输出结果。只输出代码。
Pass criteria:
- 使用点前缀位运算符,如
.&、.|、.!和.^。 - 不使用普通的
&、|或~作为位运算符。
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-042: 复合赋值和自增
Prompt:
写一段 TSL 脚本,a 初始为 1,先用复合赋值加 2,
再自增一次,最后输出 a。只输出代码。
Pass criteria:
- 使用已记录的
+=和a++或++a。 - 使用
a := 1;初始化。 - 不使用
a = a + 2。
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-043: Nil 安全访问
Prompt:
写一段 TSL 示例,安全读取可能为 nil 的对象成员 value,
使用 docs/tsl 里的空安全访问写法。只输出代码。
Pass criteria:
- 使用已记录的 nil 安全访问,如
obj?.value。 - 不虚构超出已记录模式的可选链式调用形式。
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-044: 标量链式比较
Prompt:
写一段 TSL 脚本,判断 1 < 2 < 3 的连续标量比较并输出结果。
使用 docs/tsl 的链式比较写法。只输出代码。
Pass criteria:
- 使用标量链式比较,如
1 :< 2 :< 3。 - 不写 Python 风格的
1 < 2 < 3。
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-045: 类矩阵链式比较
Prompt:
写一段 TSL 脚本,对 array(1, 2, -1)、array(2, 1, 0)、array(3, 2, 1)
做逐元素链式小于比较,并输出结果数组的三个元素。只输出代码。
Pass criteria:
- 使用矩阵链式比较,如
::<。 - 使用从零开始的索引读取结果数组元素。
- 不对数组级比较使用标量
:<。
Source docs:
docs/tsl/syntax/12_matrix_and_collections.mddocs/tsl/syntax/06_expressions_and_operators.md
TSL-046: 默认参数
Prompt:
写一个 TSL 函数 AddOne,参数 a 默认值为 1,返回 a + 1。
再写脚本输出 AddOne() 和 AddOne(5)。只输出代码。
Pass criteria:
- 使用
function AddOne(a = 1);。 - 在
.tsl声明部分之前调用函数。 - 不使用不支持的默认参数语法。
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-047: 类型化默认参数
Prompt:
写一个 TSL 函数 TypedAdd,参数 a 是 integer,默认值为 1,
返回值是 integer,返回 a + 1。只输出代码。
Pass criteria:
- 使用
function TypedAdd(a: integer = 1): integer;。 - 不用逗号分隔类型化参数。
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-048: 跳过中间参数的命名参数
Prompt:
写一段 TSL 脚本,定义 TestFunc(a, b, c),调用 TestFunc(1, c: 3),
在函数里输出 b 是否为 nil。只输出代码。
Pass criteria:
- 使用命名参数语法
c: 3。 - 使用
ifNil(b)或已记录的 nil 比较检查跳过的b。 - 保持可执行调用在函数声明之前。
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-049: 带命名参数的 call
Prompt:
写一段 TSL 脚本,通过 call 调用 TestFunc,并用命名参数传 a、b、c。
TestFunc 返回 a * 100 + b * 10 + c。只输出代码。
Pass criteria:
- 使用
call("TestFunc", a: ..., b: ..., c: ...)。 - 不用
=写命名参数。 - 在
.tsl中的调用之后定义TestFunc。
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-050: varByRef 开关
Prompt:
写一段 TSL 脚本,演示 {$varByRef-} 下未修饰参数不写回,
但 var 参数仍会写回。只输出代码。
Pass criteria:
- 使用
{$varByRef-},如果需要则稍后使用{$varByRef+}恢复。 - 包含一个未修饰参数函数和一个
var参数函数。 - 不依赖其他语言的值/引用模型。
Source docs:
docs/tsl/syntax/05_functions_and_calls.mddocs/tsl/syntax/16_lexical_structure_and_compile_options.md
TSL-039: 省略真值的条件表达式
Prompt:
写一段 TSL 脚本,分别输出 2 ?: 9 和 0 ?: 9 的结果。只输出代码。
Pass criteria:
- 使用已记录的
value ?: fallback形式。 - 除非保留被测试的表达式形式,否则不重写为普通
if语句。
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-041: 位运算符
Prompt:
写一段 TSL 脚本,对两个整数演示位与、位或、位非、位异或,
并输出结果。只输出代码。
Pass criteria:
- 使用点前缀位运算符,如
.&、.|、.!和.^。 - 不使用普通的
&、|或~作为位运算符。
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-042: 复合赋值和自增
Prompt:
写一段 TSL 脚本,a 初始为 1,先用复合赋值加 2,
再自增一次,最后输出 a。只输出代码。
Pass criteria:
- 使用已记录的
+=和a++或++a。 - 使用
a := 1;初始化。 - 不使用
a = a + 2。
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-043: Nil 安全访问
Prompt:
写一段 TSL 示例,安全读取可能为 nil 的对象成员 value,
使用 docs/tsl 里的空安全访问写法。只输出代码。
Pass criteria:
- 使用已记录的 nil 安全访问,如
obj?.value。 - 不虚构超出已记录模式的可选链式调用形式。
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-044: 标量链式比较
Prompt:
写一段 TSL 脚本,判断 1 < 2 < 3 的连续标量比较并输出结果。
使用 docs/tsl 的链式比较写法。只输出代码。
Pass criteria:
- 使用标量链式比较,如
1 :< 2 :< 3。 - 不写 Python 风格的
1 < 2 < 3。
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-045: 类矩阵链式比较
Prompt:
写一段 TSL 脚本,对 array(1, 2, -1)、array(2, 1, 0)、array(3, 2, 1)
做逐元素链式小于比较,并输出结果数组的三个元素。只输出代码。
Pass criteria:
- 使用矩阵链式比较,如
::<。 - 使用从零开始的索引读取结果数组元素。
- 不对数组级比较使用标量
:<。
Source docs:
docs/tsl/syntax/12_matrix_and_collections.mddocs/tsl/syntax/06_expressions_and_operators.md
TSL-046: 默认参数
Prompt:
写一个 TSL 函数 AddOne,参数 a 默认值为 1,返回 a + 1。
再写脚本输出 AddOne() 和 AddOne(5)。只输出代码。
Pass criteria:
- 使用
function AddOne(a = 1);。 - 在
.tsl声明部分之前调用函数。 - 不使用不支持的默认参数语法。
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-047: 类型化默认参数
Prompt:
写一个 TSL 函数 TypedAdd,参数 a 是 integer,默认值为 1,
返回值是 integer,返回 a + 1。只输出代码。
Pass criteria:
- 使用
function TypedAdd(a: integer = 1): integer;。 - 不用逗号分隔类型化参数。
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-048: 跳过中间参数的命名参数
Prompt:
写一段 TSL 脚本,定义 TestFunc(a, b, c),调用 TestFunc(1, c: 3),
在函数里输出 b 是否为 nil。只输出代码。
Pass criteria:
- 使用命名参数语法
c: 3。 - 使用
ifNil(b)或已记录的 nil 比较检查跳过的b。 - 保持可执行调用在函数声明之前。
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-049: 带命名参数的 call
Prompt:
写一段 TSL 脚本,通过 call 调用 TestFunc,并用命名参数传 a、b、c。
TestFunc 返回 a * 100 + b * 10 + c。只输出代码。
Pass criteria:
- 使用
call("TestFunc", a: ..., b: ..., c: ...)。 - 不用
=写命名参数。 - 在
.tsl中的调用之后定义TestFunc。
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-050: varByRef 开关
Prompt:
写一段 TSL 脚本,演示 {$varByRef-} 下未修饰参数不写回,
但 var 参数仍会写回。只输出代码。
Pass criteria:
- 使用
{$varByRef-},如果需要则稍后使用{$varByRef+}恢复。 - 包含一个未修饰参数函数和一个
var参数函数。 - 不依赖其他语言的值/引用模型。
Source docs:
docs/tsl/syntax/05_functions_and_calls.mddocs/tsl/syntax/16_lexical_structure_and_compile_options.md
TSL-040: 逻辑运算符
Prompt:
写一段 TSL 脚本,使用 and、or、not 组合两个条件,并输出结果。
只输出代码。
Pass criteria:
- 使用
and、or和not。 - 不使用
!作为逻辑否定。
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-041: 位运算符
Prompt:
写一段 TSL 脚本,对两个整数演示位与、位或、位非、位异或,
并输出结果。只输出代码。
Pass criteria:
- 使用点前缀位运算符,如
.&、.|、.!和.^。 - 不使用普通的
&、|或~作为位运算符。
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-042: 复合赋值和自增
Prompt:
写一段 TSL 脚本,a 初始为 1,先用复合赋值加 2,
再自增一次,最后输出 a。只输出代码。
Pass criteria:
- 使用已记录的
+=和a++或++a。 - 使用
a := 1;初始化。 - 不使用
a = a + 2。
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-043: Nil 安全访问
Prompt:
写一段 TSL 示例,安全读取可能为 nil 的对象成员 value,
使用 docs/tsl 里的空安全访问写法。只输出代码。
Pass criteria:
- 使用已记录的 nil 安全访问,如
obj?.value。 - 不虚构超出已记录模式的可选链式调用形式。
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-044: 标量链式比较
Prompt:
写一段 TSL 脚本,判断 1 < 2 < 3 的连续标量比较并输出结果。
使用 docs/tsl 的链式比较写法。只输出代码。
Pass criteria:
- 使用标量链式比较,如
1 :< 2 :< 3。 - 不写 Python 风格的
1 < 2 < 3。
Source docs:
docs/tsl/syntax/06_expressions_and_operators.md
TSL-045: 类矩阵链式比较
Prompt:
写一段 TSL 脚本,对 array(1, 2, -1)、array(2, 1, 0)、array(3, 2, 1)
做逐元素链式小于比较,并输出结果数组的三个元素。只输出代码。
Pass criteria:
- 使用矩阵链式比较,如
::<。 - 使用从零开始的索引读取结果数组元素。
- 不对数组级比较使用标量
:<。
Source docs:
docs/tsl/syntax/12_matrix_and_collections.mddocs/tsl/syntax/06_expressions_and_operators.md
TSL-046: 默认参数
Prompt:
写一个 TSL 函数 AddOne,参数 a 默认值为 1,返回 a + 1。
再写脚本输出 AddOne() 和 AddOne(5)。只输出代码。
Pass criteria:
- 使用
function AddOne(a = 1);。 - 在
.tsl声明部分之前调用函数。 - 不使用不支持的默认参数语法。
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-047: 类型化默认参数
Prompt:
写一个 TSL 函数 TypedAdd,参数 a 是 integer,默认值为 1,
返回值是 integer,返回 a + 1。只输出代码。
Pass criteria:
- 使用
function TypedAdd(a: integer = 1): integer;。 - 不用逗号分隔类型化参数。
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-048: 跳过中间参数的命名参数
Prompt:
写一段 TSL 脚本,定义 TestFunc(a, b, c),调用 TestFunc(1, c: 3),
在函数里输出 b 是否为 nil。只输出代码。
Pass criteria:
- 使用命名参数语法
c: 3。 - 使用
ifNil(b)或已记录的 nil 比较检查跳过的b。 - 保持可执行调用在函数声明之前。
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-049: 带命名参数的 call
Prompt:
写一段 TSL 脚本,通过 call 调用 TestFunc,并用命名参数传 a、b、c。
TestFunc 返回 a * 100 + b * 10 + c。只输出代码。
Pass criteria:
- 使用
call("TestFunc", a: ..., b: ..., c: ...)。 - 不用
=写命名参数。 - 在
.tsl中的调用之后定义TestFunc。
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-050: varByRef 开关
Prompt:
写一段 TSL 脚本,演示 {$varByRef-} 下未修饰参数不写回,
但 var 参数仍会写回。只输出代码。
Pass criteria:
- 使用
{$varByRef-},如果需要则稍后使用{$varByRef+}恢复。 - 包含一个未修饰参数函数和一个
var参数函数。 - 不依赖其他语言的值/引用模型。
Source docs:
docs/tsl/syntax/05_functions_and_calls.mddocs/tsl/syntax/16_lexical_structure_and_compile_options.md
TSL-051: in 和 out 调用前缀
Prompt:
写一段 TSL 脚本,在 {$varByRef-} 下调用 Touch3(in a, out b, c),
演示只有 b 被写回。只输出代码。
Pass criteria:
- 使用调用端前缀
in和out。 - 使用
{$varByRef-}。 - 不在函数头中将
in/out写为类型注解。
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-052: exit 边界
Prompt:
写一段 TSL 脚本,函数 Demo(x) 在 x > 0 时 exit,
否则 return 99;输出 Demo(1) 和 Demo(0)。只输出代码。
Pass criteria:
- 在函数内使用
exit;。 - 对另一个分支使用
return 99;。 - 不将
exit视为返回显式自定义值。
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-053: 可变参数求和
Prompt:
写一个 TSL 可变参数函数 SumAll(...),遍历 Params 求和并返回。
再输出 SumAll(1, 2, 3, 4)。只输出代码。
Pass criteria:
- 使用
function SumAll(...);。 - 迭代
Params。 - 不虚构 JavaScript rest 语法。
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-054: ParamCount 和 RealParamCount
Prompt:
写一个 TSL 函数 CountArgs(a, b, ...),返回 ParamCount * 10 + RealParamCount。
输出 CountArgs(1, 2, 3, 4)。只输出代码。
Pass criteria:
- 使用
ParamCount和RealParamCount。 - 在函数头中使用尾随
...。
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-055: 用 call 转发可变参数
Prompt:
写一段 TSL 脚本,DoFunc(fc, ...) 通过 call(fc, ...) 转发参数给 Sum3。
输出 DoFunc("Sum3", 1, 2, 3)。只输出代码。
Pass criteria:
- 使用
call(fc, ...)。 - 使用
function DoFunc(fc, ...);。 - 不手动解包固定数量的可变参数。
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-056: 匿名函数变量
Prompt:
写一段 TSL 脚本,把匿名函数赋给变量 a,
匿名函数返回 x + y,然后用 call(a, 1, 2) 输出结果。只输出代码。
Pass criteria:
- 使用
a := function(x, y) begin ... end;。 - 通过
call(a, 1, 2)或已记录的##a(...)调用。 - 不仅将函数变量作为
a(1, 2)调用。
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-057: 匿名函数作为参数
Prompt:
写一段 TSL 脚本,定义 Apply(fun),内部 call(fun, 2, 3)。
调用 Apply 时直接传入一个匿名乘法函数。只输出代码。
Pass criteria:
- 将
function(x, y) begin ... end作为参数传递。 - 在
Apply内使用call(fun, 2, 3)。
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-058: findFunction 调用
Prompt:
写一段 TSL 脚本,用 findFunction("Add") 找到 Add 函数,
再用文档支持的函数值调用方式输出 Add(1, 2)。只输出代码。
Pass criteria:
- 使用
findFunction("Add")。 - 使用
##f(...)或call(f, ...)调用返回的函数。 - 不直接调用
f(...)。
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-059: thisFunction 调用
Prompt:
写一段 TSL 脚本,用 thisFunction(Add) 得到函数值,
再通过一个 Call 包装函数调用它。只输出代码。
Pass criteria:
- 使用
thisFunction(Add)。 - 使用
call(...)或已记录的包装器风格调用函数值。 - 如果使用
thisFunction,不引用Add。
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-060: 全局函数限定
Prompt:
写一段 TSL 示例,局部函数名和全局/系统函数同名时,
用 docs/tsl 里明确的全局函数限定调用写法。只输出代码。
Pass criteria:
- 使用
::FuncName(...)进行全局/系统函数限定。 - 不虚构其他语言的命名空间分隔符。
Source docs:
docs/tsl/syntax/05_functions_and_calls.md
TSL-061: 带范围的 Case 语句
Prompt:
写一段 TSL 脚本,a 为 4,用 case 判断:
1,2 输出 small;3 到 5 输出 mid;其他输出 other。只输出代码。
Pass criteria:
- 使用
case a of。 - 使用逗号标签和
3 to 5。 - 使用
else并以end结束。
Source docs:
docs/tsl/syntax/07_control_flow.md
TSL-062: Case 表达式
Prompt:
写一段 TSL 脚本,用 case 表达式给 value 赋值,
a 为 2 时 value 是 "two",否则是 "other",然后输出 value。只输出代码。
Pass criteria:
- 使用
value := case ... of ... else ... end;。 - 不在表达式形式的分支内放置
begin ... end块。
Source docs:
docs/tsl/syntax/07_control_flow.md
TSL-063: Repeat Until
Prompt:
写一段 TSL 脚本,用 repeat ... until 把 counter 从 3 减到 0,
最后输出 counter。只输出代码。
Pass criteria:
- 使用
repeat ... until counter = 0;。 - 不写
do while语法。
Source docs:
docs/tsl/syntax/07_control_flow.md
TSL-064: While 循环中的 Break
Prompt:
写一段 TSL 脚本,用 while true 循环累加 1 到 3,
i 大于 3 时 break,然后输出 sum。只输出代码。
Pass criteria:
- 使用
while true do。 - 在循环内使用
break;。 - 为多语句循环体使用 TSL 块结构。
Source docs:
docs/tsl/syntax/07_control_flow.md
TSL-065: While 循环中的 Continue
Prompt:
写一段 TSL 脚本,while 循环 i 从 1 到 4,
跳过 i = 2,只累加其他值并输出 sum。只输出代码。
Pass criteria:
- 对跳过的迭代使用
continue;。 - 不在
continue路径之后放置会导致无限循环的增量。
Source docs:
docs/tsl/syntax/07_control_flow.md
TSL-066: Try Finally
Prompt:
写一段 TSL 脚本,用 try/finally,try 中输出 "run",
finally 中输出 "cleanup"。只输出代码。
Pass criteria:
- 使用
try ... finally ... end。 - 不使用
catch或 JavaScript 风格的异常语法。
Source docs:
docs/tsl/syntax/07_control_flow.md
TSL-067: 异常元数据
Prompt:
写一段 TSL 脚本,raise "bad" 后在 except 中输出 errInfo、errLine、errNo。
只输出代码。
Pass criteria:
- 使用
exceptObject.errInfo、exceptObject.errLine和exceptObject.errNo。 - 使用
try ... except ... end。
Source docs:
docs/tsl/syntax/07_control_flow.md
TSL-068: 嵌套 Array 解构
Prompt:
写一段 TSL 脚本,从 array((1, 2), (3, 4)) 拆出 r1 和 r2,
并输出 r1[0]、r1[1]、r2[0]、r2[1]。只输出代码。
Pass criteria:
- 使用
[r1, r2] := array((1, 2), (3, 4));。 - 使用从零开始的索引读取嵌套数组元素。
Source docs:
docs/tsl/syntax/04_variables_and_constants.mddocs/tsl/syntax/12_matrix_and_collections.md
TSL-069: 行集合操作
Prompt:
写一段 TSL 脚本,对 left_rows 和 right_rows 做 union2、intersect、minus、outersect。
只输出代码。
Pass criteria:
- 使用行集合运算符
union2、intersect、minus和outersect。 - 不将
union2视为保留重复行。
Source docs:
docs/tsl/syntax/12_matrix_and_collections.md
TSL-070: 单列 filterIn
Prompt:
写一段 TSL 示例,用 filterIn 按单列从结果集中筛选命中行。
只输出代码。
Pass criteria:
- 使用已记录的
filterIn(...)形式。 - 不用
in/sqlin集合操作替换结果集筛选。
Source docs:
docs/tsl/syntax/13_resultset_and_filters.md
TSL-071: filterNotIn
Prompt:
写一段 TSL 示例,用 filterNotIn 从结果集中排除命中行。
只输出代码。
Pass criteria:
- 使用已记录的
filterNotIn(...)形式。 - 当任务要求保留筛选语义时,不使用
minus。
Source docs:
docs/tsl/syntax/13_resultset_and_filters.md
TSL-072: TS-SQL 最小查询
Prompt:
写一段 TSL 示例,对 array((1, 2), (3, 4)) 使用 TS-SQL 最小查询骨架。
只输出代码。
Pass criteria:
- 使用语法文档中已记录的 TS-SQL 查询形式。
- 不虚构普通 SQL 字符串执行。
Source docs:
docs/tsl/syntax/14_ts_sql.md
TSL-073: TS-SQL where 和 order by
Prompt:
写一段 TSL 示例,使用 TS-SQL 对数组结果集按条件过滤并排序。
只输出代码。
Pass criteria:
- 使用已记录的
where和order byTS-SQL 语法。 - 除非 TS-SQL 文档记录,否则不使用 SQL
%通配符假设。
Source docs:
docs/tsl/syntax/14_ts_sql.md
TSL-074: TS-SQL group by
Prompt:
写一段 TSL 示例,使用 TS-SQL 按字段 group by,并计算每组统计值。
只输出代码。
Pass criteria:
- 使用已记录的
group byTS-SQL 形式。 - 仅使用已记录的聚合/引用辅助函数。
Source docs:
docs/tsl/syntax/14_ts_sql.md
TSL-075: TS-SQL join
Prompt:
写一段 TSL 示例,用 TS-SQL join 两个数组结果集。只输出代码。
Pass criteria:
- 使用已记录的
join形式。 - 不虚构数据库连接或外部 SQL 执行。
Source docs:
docs/tsl/syntax/14_ts_sql.md
TSL-076: Runtime with 星号
Prompt:
写一段 TSL 示例,使用 docs/tsl 中的 with * 块环境写法。
只输出代码。
Pass criteria:
- 使用已记录的
with *语法。 - 不虚构 Python
with语义。
Source docs:
docs/tsl/syntax/10_runtime_context_and_with.md
TSL-077: Runtime with 双星号
Prompt:
写一段 TSL 示例,使用 docs/tsl 中的 with ** 块环境写法。
只输出代码。
Pass criteria:
- 使用已记录的
with **语法。 - 不超出已记录的运行时上下文形式进行泛化。
Source docs:
docs/tsl/syntax/10_runtime_context_and_with.md
TSL-078: 网格调用超时
Prompt:
写一段 TSL 示例,用 # 网格调用并带 timeout。只输出代码。
Pass criteria:
- 使用已记录的
#Func(...)和timeout N形式。 - 除非有文档记录,否则不将
timeout转换为普通函数参数。
Source docs:
docs/tsl/syntax/10_runtime_context_and_with.md
TSL-079: 全局缓存
Prompt:
写一段 TSL 示例,设置全局缓存、读取全局缓存,并判断缓存是否存在。
只输出代码。
Pass criteria:
- 使用已记录的
setGlobalCache、getGlobalCache和ifCache。 - 不虚构浏览器/本地存储风格的 API。
Source docs:
docs/tsl/syntax/10_runtime_context_and_with.md
TSL-080: 条件编译
Prompt:
写一段 TSL 示例,使用 {$ifdef ...} 和 {$else} 做条件编译分支。
只输出代码。
Pass criteria:
- 使用已记录的编译选项语法。
- 当任务要求条件编译时,不写运行时
if。
Source docs:
docs/tsl/syntax/16_lexical_structure_and_compile_options.md
TSL-081: 注释和标识符
Prompt:
写一段 TSL 示例,包含 docs/tsl 支持的注释写法和一个普通标识符赋值。
只输出代码。
Pass criteria:
- 使用词法结构页面中已记录的注释语法。
- 使用
:=进行赋值。
Source docs:
docs/tsl/syntax/16_lexical_structure_and_compile_options.md
TSL-082: goto 标签
Prompt:
写一段 TSL 示例,使用 goto 跳转到标签并输出结果。只输出代码。
Pass criteria:
- 使用已记录的
goto和标签语法。 - 如果与文档不同,不虚构 C 风格标签规则。
Source docs:
docs/tsl/syntax/15_debug_and_profiler.md
TSL-083: debugReturn
Prompt:
写一段 TSL 示例,使用 debugReturn 提前返回调试值。只输出代码。
Pass criteria:
- 使用已记录的
debugReturn形式。 - 除非两者都需要,否则不将其与普通
return混淆。
Source docs:
docs/tsl/syntax/15_debug_and_profiler.md
TSL-084: 性能分析计时
Prompt:
写一段 TSL 示例,使用 mtic 和 mtoc 做简单计时。只输出代码。
Pass criteria:
- 使用已记录的
mtic/mtoc形式。 - 不虚构外部计时 API。
Source docs:
docs/tsl/syntax/15_debug_and_profiler.md
TSL-085: External 函数声明
Prompt:
写一个 TSL external 函数声明示例,按 docs/tsl 的最小 external 写法。
只输出代码。
Pass criteria:
- 使用已记录的
external声明形式。 - 不虚构 C、Python 或 TypeScript 的 FFI 语法。
Source docs:
docs/tsl/syntax/18_external_calls_and_threads.md
TSL-086: External 过程声明
Prompt:
写一个 TSL procedure external 示例。只输出代码。
Pass criteria:
- 使用已记录的
procedure external形式。 - 不在 procedure 头上放置返回类型。
Source docs:
docs/tsl/syntax/18_external_calls_and_threads.md
TSL-087: 原生函数指针包装器
Prompt:
写一段 TSL 示例,按 docs/tsl 包装原生函数指针。只输出代码。
Pass criteria:
- 仅使用已记录的原生函数指针包装器形式。
- 不虚构原始指针语法。
Source docs:
docs/tsl/syntax/18_external_calls_and_threads.md
TSL-088: 线程最小模式
Prompt:
写一段 TSL 线程模式最小正例,按 docs/tsl 的线程示例组织。
只输出代码。
Pass criteria:
- 使用已记录的线程模式语法。
- 不虚构 async/await 或 JavaScript 线程语法。
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:
- 使用已记录的
property Name read ... write ...形式。 - 使用
type Box = class。 - 使用
new Box()创建。
Source docs:
docs/tsl/syntax/08_objects_and_classes.md
TSL-090: 类型化 Class Property
Prompt:
写一个 TSL 类 Person,包含 string 类型字段 name_,
并定义带类型注解的 property Name。只输出代码。
Pass criteria:
- 使用字段类型注解,如
name_: string;。 - 使用已记录的类型化 property 形式。
- 不虚构 C# property 块。
Source docs:
docs/tsl/syntax/08_objects_and_classes.md
TSL-091: 方法重载
Prompt:
写一个 TSL 类 Calc,包含两个同名 Add 方法,参数个数不同。
只输出代码。
Pass criteria:
- 使用已记录的
overload方法形式。 - 将方法保持在
type Calc = class内。
Source docs:
docs/tsl/syntax/08_objects_and_classes.md
TSL-092: 继承
Prompt:
写一个 TSL 类 Animal 和继承它的 Dog,Dog 增加一个方法 Speak。
只输出代码。
Pass criteria:
- 使用
type Dog = class(Animal)。 - 不使用
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:
- 使用已记录的
virtual和override。 - 使用
type Child = class(Base)。 - 使用
new Child()创建。
Source docs:
docs/tsl/syntax/08_objects_and_classes.md
TSL-094: Inherited 方法调用
Prompt:
写一个 TSL 子类方法,在方法里调用父类同名方法后再追加自己的逻辑。
只输出代码。
Pass criteria:
- 使用已记录的
Inherited调用形式。 - 不虚构
super.method()语法。
Source docs:
docs/tsl/syntax/08_objects_and_classes.md
TSL-095: 类外 Class 方法实现
Prompt:
写一个 TSL 类 Greeter,类内只声明 Say 方法,
在类外用 ClassName.Method 形式实现它。只输出代码。
Pass criteria:
- 使用 class 声明加
function Greeter.Say(...)实现。 - 不在实现部分之后追加可执行脚本语句。
Source docs:
docs/tsl/syntax/08_objects_and_classes.md
TSL-096: 通过字符串类名 createObject
Prompt:
写一段 TSL 示例,用字符串类名通过 createObject 创建本地类实例。
只输出代码。
Pass criteria:
- 使用已记录的
createObject("ClassName")形式。 - 仅在解释它不是请求的字符串名称路径时使用
new ClassName()。
Source docs:
docs/tsl/syntax/08_objects_and_classes.md
TSL-097: 析构函数
Prompt:
写一个 TSL 类,定义无参 destroy 函数,在对象引用设为 nil 时触发清理。
只输出代码。
Pass criteria:
- 使用
function destroy();。 - 在可执行脚本代码中将对象引用设为
nil。 - 不虚构
destructor关键字。
Source docs:
docs/tsl/syntax/08_objects_and_classes.md
TSL-098: FMArray 基础
Prompt:
写一段 TSL 示例,创建 FMArray,判断它是 FMArray,并输出尺寸信息。
只输出代码。
Pass criteria:
- 使用 FMArray 页面中已记录的 FMArray 构造。
- 使用已记录的 FMArray 类型/大小辅助函数。
- 不将普通
array(...)视为自动成为 FMArray。
Source docs:
docs/tsl/syntax/23_fmarray.md
TSL-099: 矩阵深入
Prompt:
写一段 TSL 示例,初始化矩阵并使用 mrows、mcols、msize 输出维度。
只输出代码。
Pass criteria:
- 使用已记录的矩阵初始化。
- 使用
mrows、mcols和msize。
Source docs:
docs/tsl/syntax/22_matrix_deep_dive.md
TSL-100: 对象运算符重载
Prompt:
写一个 TSL 类,重载二元 + 运算符,让两个对象相加得到一个新对象。
只输出代码。
Pass criteria:
- 使用已记录的
operator +重载形式。 - 将重载实现保持在有效的
type Name = class结构内。 - 不虚构 Python
__add__或 C++ 语法。
Source docs:
docs/tsl/syntax/24_object_overloads_and_iteration.md
结果表模板
为每个评估的 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 |