add some dsl examples
This commit is contained in:
52
example/showcase/05-pattern-expansion.jdg
Normal file
52
example/showcase/05-pattern-expansion.jdg
Normal file
@@ -0,0 +1,52 @@
|
||||
// Автогенерация тестов из папки с файлами. Удобно когда тестов много и
|
||||
// вручную выписывать каждый через test("...") { stdin = ... stdout = ... }
|
||||
// будет слишком громоздко.
|
||||
//
|
||||
// Два режима:
|
||||
// 1) file-glob — пары .in/.ans файлов
|
||||
// 2) dir-mode — каждый тест лежит в своей подпапке с фиксированными
|
||||
// именами input/output файлов
|
||||
|
||||
toolchains {
|
||||
gcc { platforms = "linux" }
|
||||
}
|
||||
|
||||
build "release" {
|
||||
language = "c"
|
||||
standard = "c11"
|
||||
sources = "solution.c"
|
||||
output = "solution"
|
||||
profile = release
|
||||
}
|
||||
|
||||
// Режим 1: глобы на input и output файлы.
|
||||
// Тестом становится каждая пара (tests/*.in, tests/*.ans) с совпадающим
|
||||
// базовым именем. Имя теста — имя файла без расширения.
|
||||
group("from-files") {
|
||||
weight = 0.5
|
||||
|
||||
pattern {
|
||||
input = "tests/*.in"
|
||||
output = "tests/*.ans"
|
||||
}
|
||||
}
|
||||
|
||||
// Режим 2: каждый тест — подкаталог с фиксированным layout'ом.
|
||||
// Ожидается структура:
|
||||
// cases/
|
||||
// 01-basic/
|
||||
// input.txt
|
||||
// expected.txt
|
||||
// 02-edge/
|
||||
// input.txt
|
||||
// expected.txt
|
||||
// Имя теста — имя подкаталога.
|
||||
group("from-dirs") {
|
||||
weight = 0.5
|
||||
|
||||
pattern {
|
||||
dirs = "cases/*"
|
||||
input = "input.txt"
|
||||
output = "expected.txt"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user