summaryrefslogtreecommitdiff
path: root/test cases/format/1 default
diff options
context:
space:
mode:
authorCharles Brunet <charles.brunet@optelgroup.com>2023-09-15 10:19:02 -0400
committerDylan Baker <dylan@pnwbakers.com>2024-04-08 10:43:57 -0700
commit2b37101998c82b8c4d3985d9b0695be38ec4cf76 (patch)
tree1768a7bb40fd5ceab99dd0c10899051049d282ea /test cases/format/1 default
parentbd4fd9073081bcc9f4505b9604c5cb1e8cdc300f (diff)
downloadmeson-2b37101998c82b8c4d3985d9b0695be38ec4cf76.tar.gz
meson format command
Diffstat (limited to 'test cases/format/1 default')
-rw-r--r--test cases/format/1 default/crazy_comments.meson47
-rw-r--r--test cases/format/1 default/indentation.meson73
-rw-r--r--test cases/format/1 default/meson.build14
3 files changed, 134 insertions, 0 deletions
diff --git a/test cases/format/1 default/crazy_comments.meson b/test cases/format/1 default/crazy_comments.meson
new file mode 100644
index 000000000..f391ca28c
--- /dev/null
+++ b/test cases/format/1 default/crazy_comments.meson
@@ -0,0 +1,47 @@
+# SPDX-FileCopyrightText: Stone Tickle <lattis@mochiro.moe>
+# SPDX-License-Identifier: GPL-3.0-only
+
+project('a')
+
+if (
+ # comment
+ false # in a weird
+) # place! # test
+else
+endif # test2
+
+foreach a : (
+ # test 7
+ b # test 4
+) # test 6 # test 3
+endforeach
+# test 5
+
+a = [
+ 1,
+ # inner
+ 2, # between comma
+ # between comma 2
+] # trailing
+
+(
+ # hello
+ a()
+)
+(
+ # comment 1
+ # comment 2
+ # comment 3
+ a # comment 4
+ # comment 5
+ # comment 6
+ = (
+ # comment 7
+ 1 # comment 8
+ # comment 9
+ + 2 # comment 10
+ ) # comment 11
+ # comment 12
+) # comment 13
+
+# trailing comment
diff --git a/test cases/format/1 default/indentation.meson b/test cases/format/1 default/indentation.meson
new file mode 100644
index 000000000..31a809abf
--- /dev/null
+++ b/test cases/format/1 default/indentation.meson
@@ -0,0 +1,73 @@
+project(
+ 'indentation',
+ default_options: {
+ 'buildtype': 'release',
+ 'default_library': 'shared',
+ 'prefer_static': false,
+ 'unity': 'off',
+ },
+ meson_version: '>= 1.5.0',
+ version: '1.2.3',
+)
+
+a = [
+ 1,
+ 2,
+ 3,
+ [
+ 4,
+ 5,
+ 6,
+ [
+ 7,
+ 8,
+ 9,
+ [
+ 10, # 10
+ 11, # 11
+ 12, # 12
+ ],
+ 13,
+ 14,
+ 15,
+ ],
+ ],
+]
+d = {}
+
+if meson.project_version().version_compare('>1.2')
+ if meson.version().version_compare('>1.0')
+ foreach i : a
+ e = {
+ 'a': 'a',
+ 'b': 'b',
+ 'c': 'c',
+ 'd': [
+ 1,
+ 2,
+ 3,
+ {
+ 'e': 'e',
+ 'f': 'f',
+ 'g': 'g',
+ 'h': {
+ 'i': (
+ # a
+ 1
+ # b
+ +
+ # c
+ 2
+ ),
+ 'j': [
+ 1, # 1
+ 2, # 2
+ 3, # 3
+ ],
+ },
+ },
+ ],
+ }
+ endforeach
+ endif
+endif
diff --git a/test cases/format/1 default/meson.build b/test cases/format/1 default/meson.build
new file mode 100644
index 000000000..5b5b1152a
--- /dev/null
+++ b/test cases/format/1 default/meson.build
@@ -0,0 +1,14 @@
+# This file is for testing meson format with default options
+
+project('default format')
+
+meson_cmd = find_program('meson')
+meson_files = {
+ 'self': files('meson.build'),
+ 'comments': files('crazy_comments.meson'),
+ 'indentation': files('indentation.meson'),
+}
+
+foreach name, f : meson_files
+ test(name, meson_cmd, args: ['format', '--check-only', f])
+endforeach