slint/internal/compiler/tests/syntax/new_syntax/input_output.slint
Olivier Goffart c990660500 Run the import pass even when building the object tree fails.
This improve the code coverage of syntax_text, so some adjustment had to
be made.
This may add more error in the main file, but this make it the same
behavior as for imported files and lsp who were already running these
passes all the time
2023-07-14 14:13:48 +02:00

105 lines
2.6 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
component Compo inherits Rectangle {
property <int> priv1: 42;
private property <int> priv2: priv1;
out property <int> output1: priv2;
in property <int> input1: output1;
in-out property <int> inout1: input1;
TouchArea {
clicked => {
priv1 = 32;
priv2 = 78;
output1 = input1;
input1 = 75;
// ^error{Assignment on a input property}
inout1 = 75;
}
pressed: true;
// ^error{Cannot assign to output property 'pressed'}
}
states [
xxx when false : {
priv1: 42;
priv2: 55;
output1: 55;
input1: 12;
// ^error{'input1' cannot be set in a state because it is input}
inout1: 78;
}
]
animate input1 {}
// ^error{Cannot animate input property 'input1'}
}
OldCompo := Rectangle {
property <int> inout2: 42;
private property <int> priv2: inout2;
out property <int> output1: priv2;
in property <int> input1: output1;
in-out property <int> inout1: input1;
TouchArea {
clicked => {
pub1 = 32;
// ^error{Unknown unqualified identifier 'pub1'}
priv2 = 78;
output1 = input1;
input1 = 75;
// ^error{Assignment on a input property}
inout1 = 75;
}
}
}
export component Foo inherits Rectangle {
c1 := OldCompo {
inout2: 42;
priv2: 55;
// ^error{Cannot assign to private property 'priv2'}
output1: 855;
// ^error{Cannot assign to output property 'output1'}
input1: 12;
inout1: 78;
animate output1 {}
// ^error{Cannot animate output property 'output1'}
animate priv2 {}
// ^error{Cannot animate private property 'priv2'}
}
c2 := Compo {
priv1: 42;
// ^error{Cannot assign to private property 'priv1'}
priv2: 55;
// ^error{Cannot assign to private property 'priv2'}
output1: 585;
// ^error{Cannot assign to output property 'output1'}
input1: 12;
inout1: 78;
}
states [
foo when true: {
c2.priv1: 45;
// ^error{'c2.priv1' cannot be set in a state because it is private}
c1.priv2: 89;
// ^error{'c1.priv2' cannot be set in a state because it is private}
c2.output1: 55;
// ^error{'c2.output1' cannot be set in a state because it is output}
}
]
}