Skip to content

Commit

Permalink
Fixes #9563 (#9566)
Browse files Browse the repository at this point in the history
* Remove flag in a test

* Get this test file to run in jest again

* Fixes #9563

---------

Co-authored-by: Jarred Sumner <[email protected]>
  • Loading branch information
Jarred-Sumner and Jarred-Sumner authored Mar 22, 2024
1 parent f90bb77 commit be4b47d
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 38 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.22)
cmake_policy(SET CMP0091 NEW)
cmake_policy(SET CMP0067 NEW)

set(Bun_VERSION "1.0.34")
set(Bun_VERSION "1.0.35")
set(WEBKIT_TAG 089023cc9078b3aa173869fd6685f3e7bed2a994)

if(APPLE AND DEFINED ENV{CI})
Expand Down
4 changes: 2 additions & 2 deletions src/bun.js/module_loader.zig
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ pub const RuntimeTranspilerStore = struct {
.source_url = duped.createIfDifferent(path.text),
.hash = 0,
};
this.resolved_source.source_code.value.WTFStringImpl.ensureHash();
this.resolved_source.source_code.ensureHash();
return;
}

Expand Down Expand Up @@ -683,7 +683,7 @@ pub const RuntimeTranspilerStore = struct {
// Before ensureHash:
// 506.00 ms 6.1% 506.00 ms WTF::StringImpl::hashSlowCase() const
//
result.value.WTFStringImpl.ensureHash();
result.ensureHash();

break :brk result;
};
Expand Down
4 changes: 4 additions & 0 deletions src/string.zig
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,10 @@ pub const String = extern struct {
return this.tag == Tag.ZigString and this.value.ZigString.isGloballyAllocated();
}

pub fn ensureHash(this: String) void {
if (this.tag == .WTFStringImpl) this.value.WTFStringImpl.ensureHash();
}

pub fn toOwnedSlice(this: String, allocator: std.mem.Allocator) ![]u8 {
switch (this.tag) {
.ZigString => return try this.value.ZigString.toOwnedSlice(allocator),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ if (process.argv.length > 2) {
const b = await launch({
headless: true,
dumpio: true,
protocol: "webDriverBiDi",
});

async function main() {
Expand Down
76 changes: 42 additions & 34 deletions test/js/bun/test/expect.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2315,7 +2315,7 @@ describe("expect()", () => {
[[1n, "abc", null, -1n, undefined], -1n],
[[Symbol.for("a")], Symbol.for("a")],
[new Set([1, 2, 3]), 1],
[new Set([[], { a: 1 }, new Headers()]), new Headers()],
...[!isJest ? [new Set([[], { a: 1 }, new Headers()]), new Headers()] : []],
[new Set(["a", "b", "c"]), "c"],
[new Set([new Map([[1, 2]])]), new Map([[1, 2]])],
[new Uint8Array([1, 2, 3]), 1],
Expand Down Expand Up @@ -3267,18 +3267,22 @@ describe("expect()", () => {
label: `Buffer.from("")`,
value: Buffer.from(""),
},
{
label: `new Headers()`,
value: new Headers(),
},
{
label: `new URLSearchParams()`,
value: new URLSearchParams(),
},
{
label: `new FormData()`,
value: new FormData(),
},
...(isBun
? [
{
label: `new Headers()`,
value: new Headers(),
},
{
label: `new URLSearchParams()`,
value: new URLSearchParams(),
},
{
label: `new FormData()`,
value: new FormData(),
},
]
: []),
{
label: `(function* () {})()`,
value: (function* () {})(),
Expand Down Expand Up @@ -3343,26 +3347,30 @@ describe("expect()", () => {
label: `Buffer.from(" ")`,
value: Buffer.from(" "),
},
{
label: `new Headers({...})`,
value: new Headers({
a: "b",
c: "d",
}),
},
{
label: `URL.searchParams`,
value: new URL("https://example.com?d=e&f=g").searchParams,
},
{
label: `FormData`,
value: (() => {
var a = new FormData();
a.append("a", "b");
a.append("c", "d");
return a;
})(),
},
...(isBun
? [
{
label: `new Headers({...})`,
value: new Headers({
a: "b",
c: "d",
}),
},
{
label: `URL.searchParams`,
value: new URL("https://example.com?d=e&f=g").searchParams,
},
{
label: `FormData`,
value: (() => {
var a = new FormData();
a.append("a", "b");
a.append("c", "d");
return a;
})(),
},
]
: []),
{
label: `generator function`,
value: (function* () {
Expand Down Expand Up @@ -4282,7 +4290,7 @@ describe("expect()", () => {
expect(expect.assertions(1)).toBeUndefined();
});

const mocked = mock(() => {});
const mocked = isBun ? mock(() => {}) : jest.fn(() => {});
mocked();

test("fail to return undefined", () => {
Expand Down

0 comments on commit be4b47d

Please sign in to comment.