Files
divkit/test_data/expression_test_data/custom_functions.json
T
4eb0da fec3dfc0bf Initial funcs support
commit_hash:78f512cfc76f18e5db8b956eaa1703e4b23e07ca
2025-11-27 01:46:36 +03:00

109 lines
2.3 KiB
JSON

{
"cases": [
{
"expression": "@{equalsQuery('some string', 'one')}",
"expected": {
"type": "boolean",
"value": false
},
"functions": [
{
"name": "equalsQuery",
"body": "@{str == query}",
"return_type": "boolean",
"arguments": [
{
"name": "str",
"type": "string"
},
{
"name": "query",
"type": "string"
}
]
}
],
"platforms": [
"ios",
"web"
]
},
{
"expression": "@{sumUp(2, 3)}",
"expected": {
"type": "integer",
"value": 5
},
"functions": [
{
"name": "sumUp",
"body": "@{num1 + num2}",
"return_type": "integer",
"arguments": [
{
"name": "num1",
"type": "integer"
},
{
"name": "num2",
"type": "integer"
}
]
}
],
"platforms": [
"ios",
"web"
]
},
{
"expression": "@{testFunction + 1}",
"expected": {
"type": "error",
"value": "Failed to evaluate [testFunction + 1]. Operator '+' cannot be applied to different types: Function and Integer."
},
"variables": [],
"functions": [
{
"name": "testFunction",
"body": "@{'result'}",
"return_type": "string",
"arguments": [
{
"name": "item",
"type": "string"
}
]
}
],
"platforms": [
"web"
]
},
{
"expression": "@{toString(myFunction)}",
"expected": {
"type": "error",
"value": "Failed to evaluate [toString(myFunction)]. Function has no matching overload for given argument types: Function."
},
"variables": [],
"functions": [
{
"name": "myFunction",
"body": "@{num * 2}",
"return_type": "integer",
"arguments": [
{
"name": "num",
"type": "integer"
}
]
}
],
"platforms": [
"web"
]
}
]
}