slint/internal/compiler/tests/syntax/expressions/image-url.slint
Olivier Goffart 255dc59ef4 Rename @image-url(..., 9slice(...)) to @image-url(..., nine-slice(...))
As per API review:
 - In the Rust and C++ API we use `set_nine_slice_edges` because the getter couldn't start with 9
 - in english we spell number less than 10 with letters and this is a name
2024-03-07 17:01:57 +01:00

48 lines
3.4 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 'nine-slice\(...\)' argument}
property <image> i8: @image-url("foo", xyz(abc));
// ^error{Expected 'nine-slice\(...\)' argument}
property <image> i9: @image-url("foo", nine-slice(abc));
// ^error{Expected number literal or '\)'}
property <image> i10: @image-url("foo", nine-slice(1 2 3));
// ^error{Expected 1 or 2 or 4 numbers}
property <image> i11: @image-url("foo", nine-slice());
// ^error{Expected 1 or 2 or 4 numbers}
property <image> i12: @image-url("foo", nine-slice(1 2 3 4 5));
// ^error{Expected 1 or 2 or 4 numbers}
property <image> i13: @image-url("foo", nine-slice(1 2 foobar 4 5));
// ^error{Expected number literal or '\)'}
property <image> i14: @image-url("foo", nine-slice);
// ^error{Syntax error: expected '\('}
property <image> i15: @image-url("foo", nine-slice,);
// ^error{Syntax error: expected '\('}
property <image> i16: @image-url("foo", nine-slice 42 42);
// ^error{Syntax error: expected '\('}
property <image> i17: @image-url("foo", nine-slice(1px)); // error reported later
property <image> i18: @image-url("foo", nine-slice(1%)); // error reported later
property <image> i19: @image-url("foo", nine-slice(1, 2));
// ^error{Arguments of nine-slice need to be separated by spaces}
property <image> i20: @image-url("foo", nine-slice(2 + 3 ));
// ^error{Expected number literal or '\)'}
property <image> i21: @image-url("foo", nine-slice(2 -3 ));
// ^error{Expected number literal or '\)'}
property <image> i22: @image-url("foo", nine-slice(-2));
// ^error{Expected number literal or '\)'}
property <image> i22: @image-url("foo", nine-slice(123456789));
}