Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(496)

Unified Diff: test/mjsunit/es6/mirror-symbols.js

Issue 297513006: Implement Mirror object for Symbols. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: test/mjsunit/es6/mirror-symbols.js
diff --git a/test/mjsunit/es6/mirror-symbols.js b/test/mjsunit/es6/mirror-symbols.js
new file mode 100644
index 0000000000000000000000000000000000000000..c2d33c393c53060ee09268f86aff66f86869d787
--- /dev/null
+++ b/test/mjsunit/es6/mirror-symbols.js
@@ -0,0 +1,37 @@
+// 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, name) {
+ // 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(name, mirror.name());
+ assertEquals('symbol', mirror.type());
+ assertTrue(mirror.isPrimitive());
+ assertEquals('Symbol "' + name + '"', mirror.toText());
+ assertSame(symbol, mirror.value());
+
+ // Parse JSON representation and check.
+ var fromJSON = eval('(' + json + ')');
+ assertEquals('symbol', fromJSON.type);
+ assertEquals(name, fromJSON.name);
+}
+
+// Test a number of different symbols.
+testSymbolMirror(Symbol("a"), "a");
+testSymbolMirror(Symbol(12), "12");
+testSymbolMirror(Symbol.for("b"), "b");
+testSymbolMirror(Symbol(), undefined);

Powered by Google App Engine
This is Rietveld 408576698