From 4792abdb7fbceef7e4ec6bf15c671b88f41c65eb Mon Sep 17 00:00:00 2001 From: Dylan Conway <35280289+dylan-conway@users.noreply.github.com> Date: Tue, 14 Mar 2023 16:50:59 -0700 Subject: Implement `toMatchSnapshot()` (#2294) * buggy snapshot * error output for failed snapshot * missing first * hints * open dir once, better cleanup * update flag * truncate on update * object and class snapshot formatting * array formatting * no function name, single item is empty array * string objects, maps, sets, promise * avoid using invalid memory * handle number objects * handle extending `Number` * boolean objects * snapshot tests and test updates * snapshot format for buffers * safer snapshot parsing * property matchers setup * strings and tests * generate classes with empty prototype * optional `propertyMatchers` parameter * new test folder structure * strings.eqlLong * globalObject.throwPretty() and expect.any tests * add updateSnapshot flag to help * move snapshot format out of `printErrorlikeObject` * empty object snapshot format * separate typed array, remove trailing comma * use `isCell`, object trailing commas * handle unicode * todo for primitive constructors * switch to `JSC.Node.Syscall.open` and `JSC.Maybe` * use js parser for snapshot files * deinit ast, log parse error * copy/paste most of `exports.ZigConsoleClient` * remove snapshot option * remove ordered properties option * remove snapshot format option from `exports.zig` * remove extra newlines * change mode * update test runner output * escape backticks faster * `bunx jest` in temp dir * remove buffered writer * add `toMatchSnapshot` to types * cleanup, switch to `pread` * cli `--update` flag * `--update-snapshots` * remove string object format --- src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h') diff --git a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h index aed941a2e..a90753aa8 100644 --- a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h +++ b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h @@ -23,6 +23,12 @@ void GlobalObject::initGeneratedLazyClasses() { init.setStructure(WebCore::JSExpect::createStructure(init.vm, init.global, init.prototype)); init.setConstructor(WebCore::JSExpect::createConstructor(init.vm, init.global, init.prototype)); }); + m_JSExpectAny.initLater( + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSExpectAny::createPrototype(init.vm, reinterpret_cast(init.global))); + init.setStructure(WebCore::JSExpectAny::createStructure(init.vm, init.global, init.prototype)); + + }); m_JSFileSystemRouter.initLater( [](LazyClassStructure::Initializer& init) { init.setPrototype(WebCore::JSFileSystemRouter::createPrototype(init.vm, reinterpret_cast(init.global))); @@ -163,6 +169,7 @@ void GlobalObject::visitGeneratedLazyClasses(GlobalObject *thisObject, Visitor& thisObject->m_JSCryptoHasher.visit(visitor); visitor.append(thisObject->m_JSCryptoHasherSetterValue); thisObject->m_JSDirent.visit(visitor); visitor.append(thisObject->m_JSDirentSetterValue); thisObject->m_JSExpect.visit(visitor); visitor.append(thisObject->m_JSExpectSetterValue); + thisObject->m_JSExpectAny.visit(visitor); visitor.append(thisObject->m_JSExpectAnySetterValue); thisObject->m_JSFileSystemRouter.visit(visitor); visitor.append(thisObject->m_JSFileSystemRouterSetterValue); thisObject->m_JSListener.visit(visitor); visitor.append(thisObject->m_JSListenerSetterValue); thisObject->m_JSMD4.visit(visitor); visitor.append(thisObject->m_JSMD4SetterValue); -- cgit v1.2.3