d9736047b7
R=rossberg@chromium.org, yurys@chromium.org BUG=v8:3290 LOG=Y Review URL: https://codereview.chromium.org/297513006 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21414 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
39 lines
1.4 KiB
JavaScript
39 lines
1.4 KiB
JavaScript
// Copyright 2014 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
// Flags: --expose-debug-as debug --harmony-symbols
|
|
// Test the mirror object for symbols.
|
|
|
|
function testSymbolMirror(symbol, description) {
|
|
// Create mirror and JSON representation.
|
|
var mirror = debug.MakeMirror(symbol);
|
|
var serializer = debug.MakeMirrorSerializer();
|
|
var json = JSON.stringify(serializer.serializeValue(mirror));
|
|
|
|
// Check the mirror hierachy.
|
|
assertTrue(mirror instanceof debug.Mirror);
|
|
assertTrue(mirror instanceof debug.ValueMirror);
|
|
assertTrue(mirror instanceof debug.SymbolMirror);
|
|
|
|
// Check the mirror properties.
|
|
assertTrue(mirror.isSymbol());
|
|
assertEquals(description, mirror.description());
|
|
assertEquals('symbol', mirror.type());
|
|
assertTrue(mirror.isPrimitive());
|
|
var description_text = description === undefined ? "" : description;
|
|
assertEquals('Symbol(' + description_text + ')', mirror.toText());
|
|
assertSame(symbol, mirror.value());
|
|
|
|
// Parse JSON representation and check.
|
|
var fromJSON = eval('(' + json + ')');
|
|
assertEquals('symbol', fromJSON.type);
|
|
assertEquals(description, fromJSON.description);
|
|
}
|
|
|
|
// Test a number of different symbols.
|
|
testSymbolMirror(Symbol("a"), "a");
|
|
testSymbolMirror(Symbol(12), "12");
|
|
testSymbolMirror(Symbol.for("b"), "b");
|
|
testSymbolMirror(Symbol(), undefined);
|