Skip to content

Commit

Permalink
Add Reflect[Symbol.toStringTag].
Browse files Browse the repository at this point in the history
Summary: ECMA262 PR: tc39/ecma262#2057

Reviewed By: mhorowitz

Differential Revision: D22737738

fbshipit-source-id: 275a890c5d304bebb83643ebcc6bdf6299dc6898
  • Loading branch information
avp authored and facebook-github-bot committed Jul 25, 2020
1 parent 8ec23f7 commit 1d393b6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/VM/JSLib/Reflect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,17 @@ Handle<JSObject> createReflectObject(Runtime *runtime) {
defineReflectMethod(Predefined::set, reflectSet, 3);
defineReflectMethod(Predefined::setPrototypeOf, reflectSetPrototypeOf, 2);

DefinePropertyFlags dpf = DefinePropertyFlags::getDefaultNewPropertyFlags();
dpf.writable = 0;
dpf.enumerable = 0;
dpf.configurable = 1;
defineProperty(
runtime,
reflect,
Predefined::getSymbolID(Predefined::SymbolToStringTag),
runtime->getPredefinedStringHandle(Predefined::Reflect),
dpf);

return reflect;
}

Expand Down
5 changes: 5 additions & 0 deletions test/hermes/reflect.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,5 +473,10 @@ assert.equal(Reflect.setPrototypeOf(o, {}),
assert.throws(_ => Reflect.setPrototypeOf(1, proto),
TypeError);

print('Symbol.toStringTag');
// CHECK-LABEL: Symbol.toStringTag

assert.equal(Reflect[Symbol.toStringTag], 'Reflect');

print('done');
// CHECK-LABEL: done

0 comments on commit 1d393b6

Please sign in to comment.