slint/internal/compiler/tests/syntax/basic/tr2.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

41 lines
2.9 KiB
Text
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. 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 component X {
property <string> t1: @tr("fo{}oo", 42px);
// ^error{Cannot convert length to string. Divide by 1px to convert to a plain number}
property <string> t2: @tr("foo{0⃣}bar", 45);
// ^error{Invalid '{...}' placeholder in format string. The placeholder must be a number, or braces must be escaped with '{{' and '}}'}
property <string> t6: @tr("foo{", 45);
// ^error{Unterminated placeholder in format string. '{' must be escaped with '{{'}
property <string> t7: @tr("foo{bar", 45);
// ^error{Unterminated placeholder in format string. '{' must be escaped with '{{'}
property <string> t8: @tr("foo{bar}bar", 45);
// ^error{Invalid '{...}' placeholder in format string. The placeholder must be a number, or braces must be escaped with '{{' and '}}'}
property <string> t9: @tr("foo{}bar");
// ^error{Format string contains 1 placeholders, but only 0 extra arguments were given}
property <string> t10: @tr("foo{}ba{}r", 42);
// ^error{Format string contains 2 placeholders, but only 1 extra arguments were given}
property <string> t11: @tr("foo{65535}ba{2147483647}r");
// ^error{Invalid '{...}' placeholder in format string. The placeholder must be a number, or braces must be escaped with '{{' and '}}'}
// ^^error{Format string contains 65536 placeholders, but only 0 extra arguments were given}
property <string> t12: @tr("foo{45}bar", 44);
// ^error{Format string contains 46 placeholders, but only 1 extra arguments were given}
property <string> t13: @tr("foo{0}ba{}r", 44, 42);
// ^error{Cannot mix positional and non-positional placeholder in format string}
property <string> t14: @tr("foo{}ba{1}r", 44, 42);
// ^error{Cannot mix positional and non-positional placeholder in format string}
property <string> t15: @tr("fooba🥸{3}🥸r", 44, 42, 45);
// ^error{Format string contains 4 placeholders, but only 3 extra arguments were given}
property <string> t16: @tr("foo{} {}ba{}r", 44, 42);
// ^error{Format string contains 3 placeholders, but only 2 extra arguments were given}
property <string> t17: @tr("fo{}o}r", 44, 42);
// ^error{Unescaped '}' in format string. Escape '}' with '}}'}
property <string> ctx: @tr("foo" => "fo{}or{}", 42px);
// ^error{Format string contains 2 placeholders, but only 1 extra arguments were given}
// ^^error{Cannot convert length to string. Divide by 1px to convert to a plain number}
}