slint/sixtyfps_compiler/tests/syntax/basic/condition_operator.60
2021-08-17 22:38:16 +02:00

49 lines
1.7 KiB
Text

/* LICENSE BEGIN
This file is part of the SixtyFPS Project -- https://sixtyfps.io
Copyright (c) 2021 Olivier Goffart <olivier.goffart@sixtyfps.io>
Copyright (c) 2021 Simon Hausmann <simon.hausmann@sixtyfps.io>
SPDX-License-Identifier: GPL-3.0-only
This file is also available under commercial licensing terms.
Please contact info@sixtyfps.io for more information.
LICENSE END */
SuperSimple := Rectangle {
background: area.pressed ? green : blue;
property<color> c2: area.pressed ? 123 : 456;
// ^error{Cannot convert float to color}
property<int> c3: area.pressed ? 123 : #456;
// ^error{Cannot convert color to float}
// ^^error{Cannot convert void to int}
property<int> c4: area.pressed ? 123ms : 123;
// ^error{Cannot convert float to duration}
// ^^error{Cannot convert void to int}
property <length> c5: true ? 123px : 0;
property<duration> c6: area.pressed ? 123ms : 123;
// ^error{Cannot convert float to duration}
// ^^error{Cannot convert void to duration}
area := TouchArea {
}
}
Test2 := Rectangle {
background: {
// ^error{Cannot convert void to brush}
if (true) {
} else {
blue;
}
}
x: { if (false) {0}; }
// ^error{Cannot convert void to length}
y: { if (false) {0px} else { return 5px; }; }
property<length> something: { if (true) {"hello"} else { return 5px; }; }
// ^error{Cannot convert string to length}
}