Files
divkit/test_data/expression_test_data/functions_to_string.json
T
4eb0da 082d4ebe89 toString for arrays and dicts
201c4203e883ff3f85e3d0d5cefdc023896546a1
2024-05-16 13:58:17 +03:00

315 lines
6.4 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",
"ios"
]
},
{
"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": "toString(array) => string",
"expression": "@{toString(array)}",
"expected": {
"type": "string",
"value": "[\"string\",[123,123.45,true]]"
},
"variables": [
{
"type": "array",
"name": "array",
"value": [
"string",
[
123,
123.45,
true
]
]
}
],
"platforms": [
"ios",
"web"
]
},
{
"name": "toString(dict) => string",
"expression": "@{toString(dict)}",
"expected": {
"type": "string",
"value": "{\"boolean\":true,\"dict\":{\"integer\":123,\"number\":123.45},\"string\":\"value\"}"
},
"variables": [
{
"type": "dict",
"name": "dict",
"value": {
"boolean": true,
"dict": {
"integer": 123,
"number": 123.45
},
"string": "value"
}
}
],
"platforms": [
"ios",
"web"
]
},
{
"name": "toString('abc') => 'abc'",
"expression": "@{toString('abc')}",
"expected": {
"type": "string",
"value": "abc"
},
"variables": [],
"platforms": [
"android",
"ios",
"web"
]
},
{
"name": "empty argument list => error",
"expression": "@{toString()}",
"expected": {
"type": "error",
"value": "Failed to evaluate [toString()]. Function requires non empty argument list."
},
"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 has no matching overload for given argument types: Integer, Integer."
},
"variables": [],
"platforms": [
"android",
"ios",
"web"
]
}
]
}