summaryrefslogtreecommitdiff
path: root/test cases/common/266 format string
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2023-10-26 19:23:20 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2023-10-27 17:43:03 +0300
commit3bbe66e971dfe84dcffa702c2673fb136da0a508 (patch)
treedfad22ea1a365b4584320a92f1aa592ef868e14d /test cases/common/266 format string
parentada6236f76f4fbce4313b48eeaf9d8485516fde8 (diff)
downloadmeson-3bbe66e971dfe84dcffa702c2673fb136da0a508.tar.gz
Condense test directories for RC1.
Diffstat (limited to 'test cases/common/266 format string')
-rw-r--r--test cases/common/266 format string/meson.build20
-rw-r--r--test cases/common/266 format string/meson_options.txt1
-rw-r--r--test cases/common/266 format string/test.json28
3 files changed, 49 insertions, 0 deletions
diff --git a/test cases/common/266 format string/meson.build b/test cases/common/266 format string/meson.build
new file mode 100644
index 000000000..200cfac40
--- /dev/null
+++ b/test cases/common/266 format string/meson.build
@@ -0,0 +1,20 @@
+project('test format string')
+
+# Test all supported types in message(), format(), f-string.
+foreach t : [get_option('opt'), 42, true, false, 'str', ['list'], {'dict': 'value'}]
+ message(t, '@0@'.format(t), f'@t@', [t], {'key': t})
+endforeach
+
+# Deprecated but should work with str.format().
+env = environment()
+message('@0@'.format(env))
+
+# Should fail with f-string and message()
+error_msg = 'Value other than strings, integers, bools, options, dictionaries and lists thereof.'
+testcase expect_error('message(): ' + error_msg)
+ message(env)
+endtestcase
+
+testcase expect_error('f-string: ' + error_msg)
+ message(f'@env@')
+endtestcase
diff --git a/test cases/common/266 format string/meson_options.txt b/test cases/common/266 format string/meson_options.txt
new file mode 100644
index 000000000..2e3917617
--- /dev/null
+++ b/test cases/common/266 format string/meson_options.txt
@@ -0,0 +1 @@
+option('opt', type: 'feature')
diff --git a/test cases/common/266 format string/test.json b/test cases/common/266 format string/test.json
new file mode 100644
index 000000000..2369864b2
--- /dev/null
+++ b/test cases/common/266 format string/test.json
@@ -0,0 +1,28 @@
+{
+ "stdout": [
+ {
+ "line": "Message: auto auto auto [auto] {'key' : auto}"
+ },
+ {
+ "line": "Message: 42 42 42 [42] {'key' : 42}"
+ },
+ {
+ "line": "Message: true true true [true] {'key' : true}"
+ },
+ {
+ "line": "Message: false false false [false] {'key' : false}"
+ },
+ {
+ "line": "Message: str str str ['str'] {'key' : 'str'}"
+ },
+ {
+ "line": "Message: ['list'] ['list'] ['list'] [['list']] {'key' : ['list']}"
+ },
+ {
+ "line": "Message: {'dict' : 'value'} {'dict' : 'value'} {'dict' : 'value'} [{'dict' : 'value'}] {'key' : {'dict' : 'value'}}"
+ },
+ {
+ "line": "Message: <EnvironmentVariables: []>"
+ }
+ ]
+ }