mirror of
https://github.com/oven-sh/bun
synced 2026-02-13 12:29:07 +00:00
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
This commit is contained in:
@@ -3227,13 +3227,21 @@ void JSC__VM__releaseWeakRefs(JSC__VM* arg0)
|
||||
static auto function_string_view = MAKE_STATIC_STRING_IMPL("Function");
|
||||
void JSC__JSValue__getClassName(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, ZigString* arg2)
|
||||
{
|
||||
JSC::JSCell* cell = JSC::JSValue::decode(JSValue0).asCell();
|
||||
JSValue value = JSValue::decode(JSValue0);
|
||||
JSC::JSCell* cell = value.asCell();
|
||||
if (cell == nullptr) {
|
||||
arg2->len = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
const char* ptr = cell->className();
|
||||
JSObject* obj = value.toObject(arg1);
|
||||
StringView calculated = StringView(JSObject::calculatedClassName(obj));
|
||||
if (calculated.length() > 0) {
|
||||
*arg2 = Zig::toZigString(calculated);
|
||||
return;
|
||||
}
|
||||
|
||||
const char* ptr = cell->classInfo()->className;
|
||||
auto view = WTF::StringView(ptr, strlen(ptr));
|
||||
|
||||
// Fallback to .name if className is empty
|
||||
@@ -3784,6 +3792,12 @@ void JSC__JSValue__forEachPropertyOrdered(JSC__JSValue JSValue0, JSC__JSGlobalOb
|
||||
}
|
||||
}
|
||||
|
||||
bool JSC__JSValue__isConstructor(JSC__JSValue JSValue0)
|
||||
{
|
||||
JSValue value = JSValue::decode(JSValue0);
|
||||
return value.isConstructor();
|
||||
}
|
||||
|
||||
extern "C" JSC__JSValue JSC__JSValue__createRopeString(JSC__JSValue JSValue0, JSC__JSValue JSValue1, JSC__JSGlobalObject* globalObject)
|
||||
{
|
||||
return JSValue::encode(JSC::jsString(globalObject, JSC::JSValue::decode(JSValue0).toString(globalObject), JSC::JSValue::decode(JSValue1).toString(globalObject)));
|
||||
|
||||
Reference in New Issue
Block a user