We present a small, formal language for specifying the behavior of simple console I/O programs. The design is driven by the concrete application case of testing interactive Haskell programs written by students. Specifications are structurally similar to lexical analysis regular expressions, but are augmented with features like global variables that track state and history of program runs, enabling expression of an interesting range of dynamic behavior. We give a semantics for our specification language based on acceptance of execution traces. From this semantics we derive a definition of the set of all traces valid for a given specification. Sampling that set enables us to mechanically check program behavior against specifications in a probabilistic fashion. Beyond testing, other possible uses of the specification language in an education context include related activities like providing more helpful feedback, generating sample solutions, and even generating random exercise tasks.
翻译:我们为指定简单的控制台 I/ O 程序的行为提供了一种小的、正式的语言。 设计是由测试学生编写的交互式哈斯凯尔程序的具体应用案例驱动的。 规格在结构上类似于常规语言分析, 但增加了一些特征, 比如跟踪程序运行状态和历史的全球变量, 使得能够表达一系列有趣的动态行为。 我们根据接受执行痕迹, 给我们的规格语言提供了一种语义。 我们从这个语义中得出了对特定规格有效的所有痕迹的定义 。 抽样让我们能够机械地检查程序行为与规格的概率化方式。 除了测试之外, 在教育背景下, 规格语言的其他可能用途包括相关活动, 比如提供更有用的反馈, 生成样本解决方案, 甚至产生随机练习任务 。