slint/internal/compiler/tests/syntax/expressions/image-url.slint
2024-02-13 14:46:27 +01:00

48 lines
3.2 KiB
Text

// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial
export component SuperSimple {
property <image> i1: @image-url("hello.png");
property <string> path;
property <image> i2: @image-url(path);
// ^error{@image-url must contain a plain path as a string literal}
property <image> i3: @image-url("/home/\{path}.png");
// ^error{@image-url must contain a plain path as a string literal, without any '\\\{}' expressions}
property <image> i4: @image-url("/home/" + path + ".png");
// ^error{Expected '\)' or ','}
property <image> i5: @image-url(path + ".png");
// ^error{@image-url must contain a plain path as a string literal}
property <image> i6: @image-url;
// ^error{Syntax error: expected '\('}
property <image> i7: @image-url("foo", "bar");
// ^error{Expected '9slice\(...\)' argument}
property <image> i8: @image-url("foo", xyz(abc));
// ^error{Expected '9slice\(...\)' argument}
property <image> i9: @image-url("foo", 9slice(abc));
// ^error{Expected number literal or '\)'}
property <image> i10: @image-url("foo", 9slice(1 2 3));
// ^error{Expected 1 or 2 or 4 numbers}
property <image> i11: @image-url("foo", 9slice());
// ^error{Expected 1 or 2 or 4 numbers}
property <image> i12: @image-url("foo", 9slice(1 2 3 4 5));
// ^error{Expected 1 or 2 or 4 numbers}
property <image> i13: @image-url("foo", 9slice(1 2 foobar 4 5));
// ^error{Expected number literal or '\)'}
property <image> i14: @image-url("foo", 9slice);
// ^error{Syntax error: expected '\('}
property <image> i15: @image-url("foo", 9slice,);
// ^error{Syntax error: expected '\('}
property <image> i16: @image-url("foo", 9slice 42 42);
// ^error{Syntax error: expected '\('}
property <image> i17: @image-url("foo", 9slice(1px)); // error reported later
property <image> i18: @image-url("foo", 9slice(1%)); // error reported later
property <image> i19: @image-url("foo", 9slice(1, 2));
// ^error{Arguments of 9slice need to be separated by spaces}
property <image> i20: @image-url("foo", 9slice(2 + 3 ));
// ^error{Expected number literal or '\)'}
property <image> i21: @image-url("foo", 9slice(2 -3 ));
// ^error{Expected number literal or '\)'}
property <image> i22: @image-url("foo", 9slice(-2));
// ^error{Expected number literal or '\)'}
property <image> i22: @image-url("foo", 9slice(123456789));
}