aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorDanielGavin <danielgavin5@hotmail.com>2023-08-06 21:47:06 +0200
committerDanielGavin <danielgavin5@hotmail.com>2023-08-06 21:47:06 +0200
commit2b609359cb5a827568fcee957529d852ff7e1c40 (patch)
tree34f50f81447d3d23c818763ed1506ee0b37996ee /tools
parenta010fd2c8f9c3b3bd4cec75022c50aac94c0cb02 (diff)
Undo the control of newlines in comp_lit - it broke too many things and wasn't really compatible with the formatter design.
Diffstat (limited to 'tools')
-rw-r--r--tools/odinfmt/snapshot/snapshot.odin1
-rw-r--r--tools/odinfmt/tests/.snapshots/comp_lit.odin39
-rw-r--r--tools/odinfmt/tests/comp_lit.odin25
-rw-r--r--tools/odinfmt/tests/random/.snapshots/demo.odin79
-rw-r--r--tools/odinfmt/tests/random/.snapshots/document.odin24
5 files changed, 38 insertions, 130 deletions
diff --git a/tools/odinfmt/snapshot/snapshot.odin b/tools/odinfmt/snapshot/snapshot.odin
index ef6239d..23ae0b8 100644
--- a/tools/odinfmt/snapshot/snapshot.odin
+++ b/tools/odinfmt/snapshot/snapshot.odin
@@ -19,7 +19,6 @@ format_file :: proc(
style := format.default_style
style.character_width = 80
style.newline_style = .LF //We want to make sure it works on linux and windows.
- style.multiline_composite_literals = true
if data, ok := os.read_entire_file(filepath, allocator); ok {
return format.format(
diff --git a/tools/odinfmt/tests/.snapshots/comp_lit.odin b/tools/odinfmt/tests/.snapshots/comp_lit.odin
index a2b8a29..b7c018c 100644
--- a/tools/odinfmt/tests/.snapshots/comp_lit.odin
+++ b/tools/odinfmt/tests/.snapshots/comp_lit.odin
@@ -6,50 +6,23 @@ main :: proc() {
a, b, c, d: int,
}
_ = T{0, 0, 0, 0}
- _ = T{
- 0,
- 0,
- 0,
- 0,
- }
- _ = T{
- 0,
- 0,
- 0,
- 0,
- }
- _ = T{
- 0,
- 0,
- 0,
- 0,
- }
- _ = T{
- a = 0,
- b = 0,
- c = 0,
- d = 0,
- }
- _ = T{
- a = 0,
- b = 0,
- c = 0,
- d = 0,
- }
- _ = T{
+
+
+ _ = T {
a = 0,
b = 0,
c = 0,
d = 0,
}
- _ = T{
+
+ _ = T {
a = 0,
b = 0,
c = 0,
d = 0,
}
- sort.sort(sort.Interface{
+ sort.sort(sort.Interface {
len = proc(it: sort.Interface) -> int {
c := 2
},
diff --git a/tools/odinfmt/tests/comp_lit.odin b/tools/odinfmt/tests/comp_lit.odin
index 8859cb0..0b7e568 100644
--- a/tools/odinfmt/tests/comp_lit.odin
+++ b/tools/odinfmt/tests/comp_lit.odin
@@ -6,29 +6,10 @@ main :: proc() {
a, b, c, d: int,
}
_ = T{0,0,0,0}
- _ = T{
- 0,0,0,0,
- }
- _ = T{
- 0,
- 0,
- 0,
- 0,
- }
- _ = T{
- 0,0,
- 0,0,
- }
+
+
_ = T{a=0,b=0,c=0,d=0}
- _ = T{
- a=0,b=0,c=0,d=0,
- }
- _ = T{
- a=0,
- b=0,
- c=0,
- d=0,
- }
+
_ = T{
a=0,b=0,
c=0,d=0,
diff --git a/tools/odinfmt/tests/random/.snapshots/demo.odin b/tools/odinfmt/tests/random/.snapshots/demo.odin
index a55af51..c8cfece 100644
--- a/tools/odinfmt/tests/random/.snapshots/demo.odin
+++ b/tools/odinfmt/tests/random/.snapshots/demo.odin
@@ -203,7 +203,7 @@ control_flow :: proc() {
}
- some_map := map[string]int{
+ some_map := map[string]int {
"A" = 1,
"C" = 9,
"B" = 4,
@@ -539,7 +539,7 @@ struct_type :: proc() {
// You can list just a subset of the fields if you specify the
// field by name (the order of the named fields does not matter):
- v = Vector3{
+ v = Vector3 {
z = 1,
y = 2,
}
@@ -688,7 +688,7 @@ union_type :: proc() {
// See `parametric_polymorphism` procedure for details
new_entity :: proc($T: typeid) -> ^Entity {
t := new(Entity)
- t.derived = T{
+ t.derived = T {
entity = t,
}
return t
@@ -1131,29 +1131,15 @@ parametric_polymorphism :: proc() {
return
}
- x := [2][3]f32{
- {1, 2, 3},
- {3, 2, 1},
- }
- y := [3][2]f32{
- {0, 8},
- {6, 2},
- {8, 4},
- }
+ x := [2][3]f32{{1, 2, 3}, {3, 2, 1}}
+ y := [3][2]f32{{0, 8}, {6, 2}, {8, 4}}
z := mul(x, y)
assert(z == {{36, 24}, {20, 32}})
}
}
-prefix_table := [?]string{
- "White",
- "Red",
- "Green",
- "Blue",
- "Octarine",
- "Black",
-}
+prefix_table := [?]string{"White", "Red", "Green", "Blue", "Octarine", "Black"}
print_mutex := b64(false)
@@ -1780,7 +1766,7 @@ ranged_fields_for_array_compound_literals :: proc() {
fmt.println(foo)
}
{ // Indexed
- foo := [?]int{
+ foo := [?]int {
3 = 16,
1 = 4,
2 = 9,
@@ -1790,7 +1776,7 @@ ranged_fields_for_array_compound_literals :: proc() {
}
{ // Ranges
i := 2
- foo := [?]int{
+ foo := [?]int {
0 = 123,
5 ..= 9 = 54,
10 ..< 16 = i * 3 + (i - 1) * 2,
@@ -1800,7 +1786,7 @@ ranged_fields_for_array_compound_literals :: proc() {
}
{ // Slice and Dynamic Array support
i := 2
- foo_slice := []int{
+ foo_slice := []int {
0 = 123,
5 ..= 9 = 54,
10 ..< 16 = i * 3 + (i - 1) * 2,
@@ -1808,7 +1794,7 @@ ranged_fields_for_array_compound_literals :: proc() {
assert(len(foo_slice) == 16)
fmt.println(foo_slice) // [123, 0, 0, 0, 0, 54, 54, 54, 54, 54, 8, 8, 8, 8, 8]
- foo_dynamic_array := [dynamic]int{
+ foo_dynamic_array := [dynamic]int {
0 = 123,
5 ..= 9 = 54,
10 ..< 16 = i * 3 + (i - 1) * 2,
@@ -2019,7 +2005,7 @@ constant_literal_expressions :: proc() {
using c: Bar,
}
- FOO_CONST :: Foo{
+ FOO_CONST :: Foo {
b = 2,
a = 1,
c = {3, 4},
@@ -2036,7 +2022,7 @@ constant_literal_expressions :: proc() {
fmt.println("-------")
- ARRAY_CONST :: [3]int{
+ ARRAY_CONST :: [3]int {
1 = 4,
2 = 9,
0 = 1,
@@ -2059,7 +2045,7 @@ constant_literal_expressions :: proc() {
C,
D,
}
- ENUM_ARRAY_CONST :: [Baz]int{
+ ENUM_ARRAY_CONST :: [Baz]int {
.A ..= .C = 1,
.D = 16,
}
@@ -2078,7 +2064,7 @@ constant_literal_expressions :: proc() {
D = 16,
}
#assert(len(Sparse_Baz) < len(#sparse[Sparse_Baz]int))
- SPARSE_ENUM_ARRAY_CONST :: #sparse[Sparse_Baz]int{
+ SPARSE_ENUM_ARRAY_CONST :: #sparse[Sparse_Baz]int {
.A ..= .C = 1,
.D = 16,
}
@@ -2523,12 +2509,7 @@ matrix_type :: proc() {
mat2 :: distinct matrix[2, 2]f32
mat4 :: distinct matrix[4, 4]f32
- m2 := mat2{
- 1,
- 3,
- 2,
- 4,
- }
+ m2 := mat2{1, 3, 2, 4}
m4 := mat4(m2)
assert(m4[2, 2] == 1)
@@ -2538,24 +2519,7 @@ matrix_type :: proc() {
fmt.println("mat2(m4)", mat2(m4))
assert(mat2(m4) == m2)
- b4 := mat4{
- 1,
- 2,
- 0,
- 0,
- 3,
- 4,
- 0,
- 0,
- 5,
- 0,
- 6,
- 0,
- 0,
- 7,
- 0,
- 8,
- }
+ b4 := mat4{1, 2, 0, 0, 3, 4, 0, 0, 5, 0, 6, 0, 0, 7, 0, 8}
fmt.println("b4", matrix_flatten(b4))
}
@@ -2568,16 +2532,7 @@ matrix_type :: proc() {
mat2x4 :: distinct matrix[2, 4]f32
mat4x2 :: distinct matrix[4, 2]f32
- x := mat2x4{
- 1,
- 3,
- 5,
- 7,
- 2,
- 4,
- 6,
- 8,
- }
+ x := mat2x4{1, 3, 5, 7, 2, 4, 6, 8}
y := mat4x2(x)
fmt.println("x", x)
diff --git a/tools/odinfmt/tests/random/.snapshots/document.odin b/tools/odinfmt/tests/random/.snapshots/document.odin
index 10e13b0..e309517 100644
--- a/tools/odinfmt/tests/random/.snapshots/document.odin
+++ b/tools/odinfmt/tests/random/.snapshots/document.odin
@@ -81,7 +81,7 @@ empty :: proc(allocator := context.allocator) -> ^Document {
text :: proc(value: string, allocator := context.allocator) -> ^Document {
document := new(Document, allocator)
- document^ = Document_Text{
+ document^ = Document_Text {
value = value,
}
return document
@@ -89,7 +89,7 @@ text :: proc(value: string, allocator := context.allocator) -> ^Document {
newline :: proc(amount: int, allocator := context.allocator) -> ^Document {
document := new(Document, allocator)
- document^ = Document_Newline{
+ document^ = Document_Newline {
amount = amount,
}
return document
@@ -101,7 +101,7 @@ nest :: proc(
allocator := context.allocator,
) -> ^Document {
document := new(Document, allocator)
- document^ = Document_Nest{
+ document^ = Document_Nest {
indentation = level,
document = nested_document,
}
@@ -115,7 +115,7 @@ nest_if_break :: proc(
allocator := context.allocator,
) -> ^Document {
document := new(Document, allocator)
- document^ = Document_Nest_If_Break{
+ document^ = Document_Nest_If_Break {
indentation = level,
document = nested_document,
group_id = group_id,
@@ -129,7 +129,7 @@ hang :: proc(
allocator := context.allocator,
) -> ^Document {
document := new(Document, allocator)
- document^ = Document_Nest{
+ document^ = Document_Nest {
alignment = align,
document = hanged_document,
}
@@ -141,7 +141,7 @@ enforce_fit :: proc(
allocator := context.allocator,
) -> ^Document {
document := new(Document, allocator)
- document^ = Document_Group{
+ document^ = Document_Group {
document = fitted_document,
mode = .Fit,
}
@@ -153,7 +153,7 @@ enforce_break :: proc(
allocator := context.allocator,
) -> ^Document {
document := new(Document, allocator)
- document^ = Document_Group{
+ document^ = Document_Group {
document = fitted_document,
mode = .Break,
}
@@ -165,7 +165,7 @@ align :: proc(
allocator := context.allocator,
) -> ^Document {
document := new(Document, allocator)
- document^ = Document_Align{
+ document^ = Document_Align {
document = aligned_document,
}
return document
@@ -173,7 +173,7 @@ align :: proc(
if_break :: proc(value: string, allocator := context.allocator) -> ^Document {
document := new(Document, allocator)
- document^ = Document_If_Break{
+ document^ = Document_If_Break {
value = value,
}
return document
@@ -185,7 +185,7 @@ break_with :: proc(
allocator := context.allocator,
) -> ^Document {
document := new(Document, allocator)
- document^ = Document_Break{
+ document^ = Document_Break {
value = value,
newline = newline,
}
@@ -206,7 +206,7 @@ group :: proc(
allocator := context.allocator,
) -> ^Document {
document := new(Document, allocator)
- document^ = Document_Group{
+ document^ = Document_Group {
document = grouped_document,
options = options,
}
@@ -219,7 +219,7 @@ cons :: proc(
allocator := context.allocator,
) -> ^Document {
document := new(Document, allocator)
- document^ = Document_Cons{
+ document^ = Document_Cons {
lhs = lhs,
rhs = rhs,
}