Files
divkit/test_data/expression_test_data/functions_to_string.json
T
2023-11-03 11:57:31 +03:00

260 lines
5.5 KiB
JSON

{
"cases": [
{
"name": "positive integer to string => string",
"expression": "@{toString(1)}",
"expected": {
"type": "string",
"value": "1"
},
"variables": [],
"platforms": [
"android",
"ios",
"web"
]
},
{
"name": "negative integer to string => string",
"expression": "@{toString(-1)}",
"expected": {
"type": "string",
"value": "-1"
},
"variables": [],
"platforms": [
"android",
"ios",
"web"
]
},
{
"name": "positive number to string => string",
"expression": "@{toString(3.1415)}",
"expected": {
"type": "string",
"value": "3.1415"
},
"variables": [],
"platforms": [
"android",
"ios",
"web"
]
},
{
"name": "negative number to string => string",
"expression": "@{toString(-3.1415)}",
"expected": {
"type": "string",
"value": "-3.1415"
},
"variables": [],
"platforms": [
"android",
"ios",
"web"
]
},
{
"name": "exponential number => string",
"expression": "@{toString(1e23)}",
"expected": {
"type": "string",
"value": "1.0E23"
},
"variables": [],
"platforms": [
"web"
]
},
{
"name": "number variable => string",
"expression": "@{toString(val)}",
"expected": {
"type": "string",
"value": "123.0"
},
"variables": [
{
"type": "number",
"name": "val",
"value": 123
}
],
"platforms": [
"web",
"android"
]
},
{
"name": "true boolean to string => string",
"expression": "@{toString(true)}",
"expected": {
"type": "string",
"value": "true"
},
"variables": [],
"platforms": [
"android",
"ios",
"web"
]
},
{
"name": "false boolean to string => string",
"expression": "@{toString(false)}",
"expected": {
"type": "string",
"value": "false"
},
"variables": [],
"platforms": [
"android",
"ios",
"web"
]
},
{
"name": "color with format #RGB to string => string",
"expression": "@{toString(color)}",
"expected": {
"type": "string",
"value": "#FFFFCCEE"
},
"variables": [
{
"type": "color",
"name": "color",
"value": "#fce"
}
],
"platforms": [
"android",
"ios",
"web"
]
},
{
"name": "color with format #ARGB to string => string",
"expression": "@{toString(color)}",
"expected": {
"type": "string",
"value": "#DDFFCCEE"
},
"variables": [
{
"type": "color",
"name": "color",
"value": "#dfce"
}
],
"platforms": [
"android",
"ios",
"web"
]
},
{
"name": "color with format #RRGGBB to string => string",
"expression": "@{toString(color)}",
"expected": {
"type": "string",
"value": "#FFFFCCEE"
},
"variables": [
{
"type": "color",
"name": "color",
"value": "#ffCCeE"
}
],
"platforms": [
"android",
"ios",
"web"
]
},
{
"name": "color with format #AARRGGBB to string => string",
"expression": "@{toString(color)}",
"expected": {
"type": "string",
"value": "#DDFFCCEE"
},
"variables": [
{
"type": "color",
"name": "color",
"value": "#DdffCCeE"
}
],
"platforms": [
"android",
"ios",
"web"
]
},
{
"name": "url to string => string",
"expression": "@{toString(url)}",
"expected": {
"type": "string",
"value": "https://ya.ru/?hello=1"
},
"variables": [
{
"type": "url",
"name": "url",
"value": "https://ya.ru/?hello=1"
}
],
"platforms": [
"android",
"ios",
"web"
]
},
{
"name": "string to string => error",
"expression": "@{toString('abc')}",
"expected": {
"type": "error",
"value": "Failed to evaluate [toString('abc')]. Function 'toString' has no matching override for given argument types: String."
},
"variables": [],
"platforms": [
"android",
"web"
]
},
{
"name": "empty argument list => error",
"expression": "@{toString()}",
"expected": {
"type": "error",
"value": "Failed to evaluate [toString()]. Non empty argument list is required for function 'toString'."
},
"variables": [],
"platforms": [
"android",
"ios",
"web"
]
},
{
"name": "too many arguments => error",
"expression": "@{toString(1, 1)}",
"expected": {
"type": "error",
"value": "Failed to evaluate [toString(1, 1)]. Function 'toString' has no matching override for given argument types: Integer, Integer."
},
"variables": [],
"platforms": [
"android",
"web"
]
}
]
}