slint/internal/compiler/tests/syntax/expressions/arithmetic_op.slint
Olivier Goffart 12393e21bd
syntax_tests: allow to update tests, and don't use a regexp (#8589)
* 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
2025-06-02 16:47:33 +02:00

35 lines
1.7 KiB
Text
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 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
export SuperSimple := Rectangle {
// ^warning{':=' to declare a component is deprecated. The new syntax declare components with 'component MyComponent {'. Read the documentation for more info}
property<duration> p1: 3s + 1ms;
property<int> p2: 3s + 1;
// ^error{Cannot convert float to duration. Use an unit, or multiply by 1ms to convert explicitly}
property<int> p3: 3s - 1;
// ^error{Cannot convert float to duration. Use an unit, or multiply by 1ms to convert explicitly}
property<int> p4: 3 / 1ms;
// ^error{Cannot convert (ms⁻¹) to int}
property<duration> p5: 3ms * 1;
property<duration> p6: 3ms * 1s;
// ^error{Cannot convert (ms²) to duration}
property<int> p7: "hello" * 1;
// ^error{Cannot convert string to float}
property<int> p8: 1 - "hello" - 1;
// ^error{Cannot convert string to float}
property<string> p9: 1 + "hello" + 1;
property<int> p10: "hello" + 1ms;
// ^error{Cannot convert duration to string. Divide by 1ms to convert to a plain number}
property<length> p11: 1ms * 1px *3px / 1deg * 3 / (30px * 1s - 3px * 1ms) * 2deg;
property<int> p12: 1ms * 3s / 3px / (2deg * 5turn) * 2s / 3phx;
// ^error{Cannot convert (ms³×phx⁻¹×px⁻¹×deg⁻²) to int}
property <brush> bru: background + background;
// ^error{Cannot convert brush to float}
// ^^error{Cannot convert brush to float}
}