AimonaStudio / rrreol

下一代OIer/ACMer本地代码测评的简便环境 | Next-generation OIer/ACMer code native tiny code test environment

Home Page:https://aimonastudio.github.io/rrreol

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

feature(core): Judge 部分设计思路

himself65 opened this issue · comments

judge

程序检查部分,可以通过读取.out类型文件直接进行比较,或者直接通过手动写判断来进行结果比对

// foo.cpp
#include <iostream>
using namespace std;
int main() {
  cout << "Yes" << endl;
  cout << "No" << endl;
  return 0;
}
Judge('./foo.cpp')
  .line(1).toBe('Yes')
  .line(2).toBe('False')
  .maxline().toBe(2)
  .exec() // 开始运行
  .line(2).toBe("False")
                         
                 ^^^^^^
error on "line 2", expect "False" but got "No"

部分接口大致思路

// 非标准typescript代码,保证语法不正确
interface IDataable: string | number | string[] | number[];

interface IJudgeWrapper{
  constructor(val: IJudgeWrapper | IJudge)
  toBe(val: IDataable) => this
  line: (val: string, number, (number, string)[]) => IJudgeWrapper(this)
  maxline: (val: IDataable) => IJudgeWrapper(this)
}

interface IJudge {
  line: (val: IDataable) => IJudgeWrapper(this)
  maxline: (val: Number) => IJudgeWrapper(this)
  exec: () => this
}

JudgeWrapper

包装Judge类,使其可以有toBe()notToBe() 等判断函数来测试程序输出文件

返回 Judge

Judge.prototype

Of(val)

返回一个新的Judge

file(val: file | file[] | string | string[] | null)

输入参数则直接进行测评

如果没有任何参数,则可以根据返回的fileManagerWrapper来针对每个文件的输出进行判断

exec()

运行代码

Judge Function 测评函数

以下函数都返回Judge.Of(this)

line()

针对某行进行判断

maxline()

最大行数

minline()

最小行数

实际上可以直接用coreutils里的diff来比对输出
(我也不太清楚我有没有理解到您的意思qwq)

实际上可以直接用coreutils里的diff来比对输出
(我也不太清楚我有没有理解到您的意思qwq)

util里的只有strictEqual 而我要实现的是竞赛上的一种自定义相等
比如

equal([1, 2, 3], "1 2 3") === true
equal(1, "1") === true 

应该是我没说清楚qwq

要是用 diff 的话就不必写 spj 了

另外,coreutilsGNU Core Utilities

您可以在本机上用 git diff 来尝试一下(如图)

image

应该是我没说清楚qwq

要是用 diff 的话就不必写 spj 了

另外,coreutilsGNU Core Utilities

您可以在本机上用 git diff 来尝试一下(如图)

image

不只需要这些

暂时发现这些是错误的实现,之后重新设计