mirror of
				https://github.com/slint-ui/slint.git
				synced 2025-10-31 20:08:35 +00:00 
			
		
		
		
	 12393e21bd
			
		
	
	
		12393e21bd
		
			
		
	
	
	
	
		
			
			* syntax_tests: allow to "bless" tests, and don't use a regexp
A regexp was used at the beginning because I thought we would want to
allow error to contains things that were not predictable or that would
often change. But this is not the case¹. It is better to actually test
for the full error message
¹ well actually it was the case for path, but there is another substitution to 
 `📂` for the manifest directory
* syntax_tests: Bless the tests
* syntax_tests: Manual adjust after bless
Because there used to be comments on the same line of the message which
bless don't support
* Fix error message with path on windows
 - The debug implementation of path make double slash, that's not what
   we want to show the user
 - normalize paths to use `/` so the test passes
		
	
			
		
			
				
	
	
		
			119 lines
		
	
	
	
		
			3.7 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
			
		
		
	
	
			119 lines
		
	
	
	
		
			3.7 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
| // Copyright © SixtyFPS GmbH <info@slint.dev>
 | |
| // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
 | |
| 
 | |
| global Glo {
 | |
|     property <int> priv1: 34;
 | |
|     in property <int> in1: 11;
 | |
|     out property <int> out1: 33;
 | |
|     private property <int> priv2: 55;
 | |
|     in-out property <int> inout1: 2;
 | |
| 
 | |
|     callback foo(int);
 | |
|     foo(x) => {
 | |
|         out1 = 42;
 | |
|         in1 = 55;
 | |
| //      ^error{Assignment on a input property}
 | |
|     }
 | |
| }
 | |
| 
 | |
| 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;
 | |
| 
 | |
|             self.pressed-x = 42px;
 | |
| //          ^error{Assignment on a output property}
 | |
|         }
 | |
|     }
 | |
| 
 | |
| }
 | |
| 
 | |
| OldCompo := Rectangle {
 | |
| //       ^warning{':=' to declare a component is deprecated. The new syntax declare components with 'component MyComponent {'. Read the documentation for more info}
 | |
|     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 => {
 | |
|             inout2 = 32;
 | |
|             priv2 = 78;
 | |
|             output1 = input1;
 | |
|             input1 = 75;
 | |
| //          ^error{Assignment on a input property}
 | |
|             inout1 = 75;
 | |
|             pressed-x = 45px;
 | |
| //          ^warning{Assignment on an output property is deprecated}
 | |
|             pressed-y -= 45px;
 | |
| //          ^warning{Self assignment on an output property is deprecated}
 | |
|         }
 | |
|         has-hover: true;
 | |
| //      ^warning{Assigning to output property 'has-hover' is deprecated}
 | |
|     }
 | |
| }
 | |
| 
 | |
| export component A inherits Compo {
 | |
|     input1: priv1;
 | |
| //          ^error{Unknown unqualified identifier 'priv1'}
 | |
| }
 | |
| 
 | |
| export component Foo inherits Rectangle {
 | |
| 
 | |
|     in property <[int]> input_model;
 | |
| 
 | |
|     c1 := OldCompo {
 | |
| 
 | |
|     }
 | |
| 
 | |
|     c2 := Compo {
 | |
|         inout1: self.priv1;
 | |
| //                   ^error{The property 'priv1' is private. Annotate it with 'in', 'out' or 'in-out' to make it accessible from other components}
 | |
|     }
 | |
| 
 | |
| 
 | |
|     TouchArea {
 | |
|         clicked => {
 | |
|             c1.inout2 = 32;
 | |
|             c1.priv2 = 78;
 | |
| //             ^error{The property 'priv2' is private. Annotate it with 'in', 'out' or 'in-out' to make it accessible from other components}
 | |
|             c1.output1 = c1.input1;
 | |
| //          ^error{Assignment on a output property}
 | |
|             c1.input1 = 75;
 | |
|             c1.inout1 = 75;
 | |
| 
 | |
|             c2.priv1 = 32;
 | |
| //             ^error{The property 'priv1' is private. Annotate it with 'in', 'out' or 'in-out' to make it accessible from other components}
 | |
|             c2.priv2 = 78;
 | |
| //             ^error{The property 'priv2' is private. Annotate it with 'in', 'out' or 'in-out' to make it accessible from other components}
 | |
|             c2.output1 = c1.inout2;
 | |
| //          ^error{Assignment on a output property}
 | |
|             c2.input1 = 75;
 | |
|             c2.inout1 = 75;
 | |
| 
 | |
|             input_model[42] += 12;
 | |
| //          ^error{Self assignment on a input property}
 | |
| 
 | |
|             Glo.out1 = Glo.in1;
 | |
| //          ^error{Assignment on a output property}
 | |
|             Glo.inout1 = Glo.priv1;
 | |
| //                           ^error{The property 'priv1' is private. Annotate it with 'in', 'out' or 'in-out' to make it accessible from other components}
 | |
|             Glo.priv2 = Glo.out1;
 | |
| //              ^error{The property 'priv2' is private. Annotate it with 'in', 'out' or 'in-out' to make it accessible from other components}
 | |
|             Glo.in1 = 32;
 | |
|         }
 | |
|     }
 | |
| }
 | |
| 
 |