Skip to content

Commit 3d66758

Browse files
committed
zig fmt
1 parent fc0ec86 commit 3d66758

File tree

2 files changed

+15
-30
lines changed

2 files changed

+15
-30
lines changed

src/browser/dump.zig

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ fn isVoid(elem: *parser.Element) !bool {
123123
fn writeEscapedTextNode(writer: anytype, value: []const u8) !void {
124124
var v = value;
125125
while (v.len > 0) {
126-
const index = std.mem.indexOfAnyPos(u8, v, 0, &.{'&', '<', '>'}) orelse {
126+
const index = std.mem.indexOfAnyPos(u8, v, 0, &.{ '&', '<', '>' }) orelse {
127127
return writer.writeAll(v);
128128
};
129129
try writer.writeAll(v[0..index]);
@@ -133,14 +133,14 @@ fn writeEscapedTextNode(writer: anytype, value: []const u8) !void {
133133
'>' => try writer.writeAll("&gt;"),
134134
else => unreachable,
135135
}
136-
v = v[index+1..];
136+
v = v[index + 1 ..];
137137
}
138138
}
139139

140140
fn writeEscapedAttributeValue(writer: anytype, value: []const u8) !void {
141141
var v = value;
142142
while (v.len > 0) {
143-
const index = std.mem.indexOfAnyPos(u8, v, 0, &.{'&', '<', '>', '"'}) orelse {
143+
const index = std.mem.indexOfAnyPos(u8, v, 0, &.{ '&', '<', '>', '"' }) orelse {
144144
return writer.writeAll(v);
145145
};
146146
try writer.writeAll(v[0..index]);
@@ -151,40 +151,26 @@ fn writeEscapedAttributeValue(writer: anytype, value: []const u8) !void {
151151
'"' => try writer.writeAll("&quot;"),
152152
else => unreachable,
153153
}
154-
v = v[index+1..];
154+
v = v[index + 1 ..];
155155
}
156156
}
157157

158158
const testing = std.testing;
159159
test "dump.writeHTML" {
160-
try testWriteHTML(
161-
"<div id=\"content\">Over 9000!</div>",
162-
"<div id=\"content\">Over 9000!</div>"
163-
);
164-
165-
try testWriteHTML(
166-
"<root><!-- a comment --></root>",
167-
"<root><!-- a comment --></root>"
168-
);
169-
170-
try testWriteHTML(
171-
"<p>&lt; &gt; &amp;</p>",
172-
"<p>&lt; &gt; &amp;</p>"
173-
);
174-
175-
try testWriteHTML(
176-
"<p id=\"&quot;&gt;&lt;&amp;&quot;''\">wat?</p>",
177-
"<p id='\">&lt;&amp;&quot;&#39;&apos;'>wat?</p>"
178-
);
160+
try testWriteHTML("<div id=\"content\">Over 9000!</div>", "<div id=\"content\">Over 9000!</div>");
161+
162+
try testWriteHTML("<root><!-- a comment --></root>", "<root><!-- a comment --></root>");
163+
164+
try testWriteHTML("<p>&lt; &gt; &amp;</p>", "<p>&lt; &gt; &amp;</p>");
165+
166+
try testWriteHTML("<p id=\"&quot;&gt;&lt;&amp;&quot;''\">wat?</p>", "<p id='\">&lt;&amp;&quot;&#39;&apos;'>wat?</p>");
179167

180168
try testWriteFullHTML(
181169
\\<!DOCTYPE html>
182170
\\<html><head><title>It's over what?</title><meta name="a" value="b">
183171
\\</head><body>9000</body></html>
184172
\\
185-
,
186-
"<html><title>It's over what?</title><meta name=a value=\"b\">\n<body>9000"
187-
);
173+
, "<html><title>It's over what?</title><meta name=a value=\"b\">\n<body>9000");
188174
}
189175

190176
fn testWriteHTML(comptime expected: []const u8, src: []const u8) !void {

src/generate.zig

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ test "generate.Union" {
173173
value: u8 = 0,
174174
};
175175

176-
const value = Union(.{ Astruct, Bstruct, .{ Cstruct } });
176+
const value = Union(.{ Astruct, Bstruct, .{Cstruct} });
177177
const ti = @typeInfo(value).Union;
178178
try std.testing.expectEqual(3, ti.fields.len);
179179
try std.testing.expectEqualStrings("*generate.test.generate.Union.Astruct.Other", @typeName(ti.fields[0].type));
@@ -185,8 +185,7 @@ test "generate.Union" {
185185
}
186186

187187
test "generate.Tuple" {
188-
const Astruct = struct {
189-
};
188+
const Astruct = struct {};
190189

191190
const Bstruct = struct {
192191
value: u8 = 0,
@@ -207,7 +206,7 @@ test "generate.Tuple" {
207206

208207
{
209208
// dedupe
210-
const tuple = Tuple(.{ Cstruct, Astruct, .{ Astruct }, Bstruct, .{ Astruct, .{ Astruct, Bstruct } } }){};
209+
const tuple = Tuple(.{ Cstruct, Astruct, .{Astruct}, Bstruct, .{ Astruct, .{ Astruct, Bstruct } } }){};
211210
const ti = @typeInfo(@TypeOf(tuple)).Struct;
212211
try std.testing.expectEqual(true, ti.is_tuple);
213212
try std.testing.expectEqual(3, ti.fields.len);

0 commit comments

Comments
 (0)