Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support language-specific evaluators in DSL #529

Merged
merged 2 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ij_wrap_on_typing = false
[*.nix]
indent_size = 2

[{*.json,*.yaml,*.yml}]
[{*.json,*.yaml,*.yml,*.tson}]
indent_size = 2
ij_json_keep_blank_lines_in_code = 0
ij_json_keep_indents_on_empty_lines = false
Expand Down
166 changes: 120 additions & 46 deletions tested/dsl/schema-strict.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,27 @@
}
],
"definitions" : {
"_rootObject": {
"type": "object",
"_rootObject" : {
"type" : "object",
"oneOf" : [
{
"required" : ["tabs"],
"not": {
"required" : ["units"]
"required" : [
"tabs"
],
"not" : {
"required" : [
"units"
]
}
},
{
"required" : ["units"],
"not": {
"required" : ["tabs"]
"required" : [
"units"
],
"not" : {
"required" : [
"tabs"
]
}
}
],
Expand All @@ -45,7 +53,7 @@
"tabs" : {
"$ref" : "#/definitions/_tabList"
},
"units": {
"units" : {
"$ref" : "#/definitions/_unitList"
},
"language" : {
Expand All @@ -59,9 +67,9 @@
}
]
},
"definitions": {
"description": "Define hashes to use elsewhere.",
"type": "object"
"definitions" : {
"description" : "Define hashes to use elsewhere.",
"type" : "object"
}
}
},
Expand Down Expand Up @@ -100,9 +108,9 @@
"type" : "string",
"description" : "The name of this tab."
},
"definitions": {
"description": "Define objects to use elsewhere.",
"type": "object"
"definitions" : {
"description" : "Define objects to use elsewhere.",
"type" : "object"
}
},
"oneOf" : [
Expand Down Expand Up @@ -149,9 +157,9 @@
"type" : "string",
"description" : "The name of this tab."
},
"definitions": {
"description": "Define objects to use elsewhere.",
"type": "object"
"definitions" : {
"description" : "Define objects to use elsewhere.",
"type" : "object"
}
},
"oneOf" : [
Expand All @@ -177,28 +185,28 @@
}
]
},
"_contextList": {
"_contextList" : {
"type" : "array",
"minItems" : 1,
"items" : {
"$ref" : "#/definitions/context"
}
},
"_caseList": {
"_caseList" : {
"type" : "array",
"minItems" : 1,
"items" : {
"$ref" : "#/definitions/case"
}
},
"_testcaseList": {
"_testcaseList" : {
"type" : "array",
"minItems" : 1,
"items" : {
"$ref" : "#/definitions/testcase"
}
},
"_scriptList": {
"_scriptList" : {
"type" : "array",
"minItems" : 1,
"items" : {
Expand Down Expand Up @@ -254,8 +262,8 @@
"description" : "An individual test for a statement or expression",
"additionalProperties" : false,
"properties" : {
"description": {
"$ref": "#/definitions/message"
"description" : {
"$ref" : "#/definitions/message"
},
"stdin" : {
"description" : "Stdin for this context",
Expand Down Expand Up @@ -346,8 +354,8 @@
"type" : "object",
"description" : "An individual test (script) for a statement or expression",
"properties" : {
"description": {
"$ref": "#/definitions/message"
"description" : {
"$ref" : "#/definitions/message"
},
"stdin" : {
"description" : "Stdin for this context",
Expand Down Expand Up @@ -455,7 +463,7 @@
}
]
},
"yamlValueOrPythonExpression": {
"yamlValueOrPythonExpression" : {
"oneOf" : [
{
"$ref" : "#/definitions/yamlValue"
Expand Down Expand Up @@ -494,12 +502,14 @@
{
"type" : "object",
"description" : "Built-in oracle for text values.",
"required" : ["data"],
"required" : [
"data"
],
"properties" : {
"data": {
"data" : {
"$ref" : "#/definitions/textualType"
},
"oracle": {
"oracle" : {
"const" : "builtin"
},
"config" : {
Expand All @@ -510,9 +520,13 @@
{
"type" : "object",
"description" : "Custom oracle for text values.",
"required" : ["oracle", "file", "data"],
"required" : [
"oracle",
"file",
"data"
],
"properties" : {
"oracle": {
"oracle" : {
"const" : "custom_check"
},
"file" : {
Expand All @@ -535,7 +549,7 @@
}
]
},
"returnOutputChannel": {
"returnOutputChannel" : {
"oneOf" : [
{
"$ref" : "#/definitions/yamlValueOrPythonExpression"
Expand Down Expand Up @@ -587,6 +601,63 @@
}
}
}
},
{
"type" : "oracle",
"additionalProperties" : false,
"required" : [
"oracle",
"functions"
],
"properties" : {
"oracle" : {
"const" : "specific_check"
},
"functions" : {
"minProperties" : 1,
"description" : "Language mapping of oracle functions.",
"type" : "object",
"propertyNames" : {
"$ref" : "#/definitions/programmingLanguage"
},
"items" : {
"type" : "object",
"required" : [
"file"
],
"properties" : {
"file" : {
"type" : "string",
"description" : "The path to the file containing the custom check function."
},
"name" : {
"type" : "string",
"description" : "The name of the custom check function.",
"default" : "evaluate"
}
}
}
},
"arguments" : {
"minProperties" : 1,
"description" : "Language mapping of oracle arguments.",
"type" : "object",
"propertyNames" : {
"$ref" : "#/definitions/programmingLanguage"
},
"items" : {
"type" : "array",
"description" : "List of YAML (or tagged expression) values to use as arguments to the function.",
"items" : {
"type" : "string",
"description" : "A language-specific literal, which will be used verbatim."
}
}
},
"value" : {
"$ref" : "#/definitions/yamlValueOrPythonExpression"
}
}
}
]
},
Expand All @@ -605,23 +676,23 @@
"csharp"
]
},
"message": {
"oneOf": [
"message" : {
"oneOf" : [
{
"type": "string",
"type" : "string",
"description" : "A simple message to display."
},
{
"type": "object",
"type" : "object",
"required" : [
"description"
],
"properties" : {
"description": {
"description" : {
"type" : "string",
"description" : "The message to display."
},
"format": {
"format" : {
"type" : "string",
"default" : "text",
"description" : "The format of the message, either a programming language, 'text' or 'html'."
Expand All @@ -647,9 +718,9 @@
"description" : "Ignore trailing whitespace",
"type" : "boolean"
},
"normalizeTrailingNewlines": {
"description": "Normalize trailing newlines",
"type": "boolean"
"normalizeTrailingNewlines" : {
"description" : "Normalize trailing newlines",
"type" : "boolean"
},
"roundTo" : {
"description" : "The number of decimals to round at, when applying the rounding on floats",
Expand All @@ -665,7 +736,7 @@
}
}
},
"textualType": {
"textualType" : {
"description" : "Simple textual value, converted to string.",
"type" : [
"string",
Expand All @@ -674,10 +745,13 @@
"boolean"
]
},
"yamlValue": {
"yamlValue" : {
"description" : "A value represented as YAML.",
"not": {
"type": ["oracle", "expression"]
"not" : {
"type" : [
"oracle",
"expression"
]
}
}
}
Expand Down
Loading
Loading