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

Unified Diff: third_party/closure_compiler/runner/test/com/google/javascript/jscomp/ChromePassTest.java

Issue 460163002: Handle property definition by {cr|Object}.defineProperty() in compiler pass (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@C_compiler_pass
Patch Set: rebase onto master Created 6 years, 4 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: third_party/closure_compiler/runner/test/com/google/javascript/jscomp/ChromePassTest.java
diff --git a/third_party/closure_compiler/runner/test/com/google/javascript/jscomp/ChromePassTest.java b/third_party/closure_compiler/runner/test/com/google/javascript/jscomp/ChromePassTest.java
index 4156eb93a65f9d027ec3d164618f1ec183bed083..8cef6953e4507f0c1c04e02cda78225b5f90afcc 100644
--- a/third_party/closure_compiler/runner/test/com/google/javascript/jscomp/ChromePassTest.java
+++ b/third_party/closure_compiler/runner/test/com/google/javascript/jscomp/ChromePassTest.java
@@ -184,4 +184,55 @@ public class ChromePassTest extends CompilerTestCase {
null, ChromePass.CR_DEFINE_INVALID_RETURN_IN_FUNCTION);
}
+ public void testObjectDefinePropertyDefinesUnquotedProperty() throws Exception {
+ test(
+ "Object.defineProperty(a.b, 'c', {});",
+ "Object.defineProperty(a.b, 'c', {});\n" +
+ "/** @type {?} */\n" +
+ "a.b.c;");
+ }
+
+ public void testCrDefinePropertyDefinesUnquotedPropertyWithStringTypeForPropertyKindAttr()
+ throws Exception {
+ test(
+ "cr.defineProperty(a.prototype, 'c', cr.PropertyKind.ATTR);",
+ "cr.defineProperty(a.prototype, 'c', cr.PropertyKind.ATTR);\n" +
+ "/** @type {string} */\n" +
+ "a.prototype.c;");
+ }
+
+ public void testCrDefinePropertyDefinesUnquotedPropertyWithBooleanTypeForPropertyKindBoolAttr()
+ throws Exception {
+ test(
+ "cr.defineProperty(a.prototype, 'c', cr.PropertyKind.BOOL_ATTR);",
+ "cr.defineProperty(a.prototype, 'c', cr.PropertyKind.BOOL_ATTR);\n" +
+ "/** @type {boolean} */\n" +
+ "a.prototype.c;");
+ }
+
+ public void testCrDefinePropertyDefinesUnquotedPropertyWithAnyTypeForPropertyKindJs()
+ throws Exception {
+ test(
+ "cr.defineProperty(a.prototype, 'c', cr.PropertyKind.JS);",
+ "cr.defineProperty(a.prototype, 'c', cr.PropertyKind.JS);\n" +
+ "/** @type {?} */\n" +
+ "a.prototype.c;");
+ }
+
+ public void testCrDefinePropertyDefinesUnquotedPropertyOnPrototypeWhenFunctionIsPassed()
+ throws Exception {
+ test(
+ "cr.defineProperty(a, 'c', cr.PropertyKind.JS);",
+ "cr.defineProperty(a, 'c', cr.PropertyKind.JS);\n" +
+ "/** @type {?} */\n" +
+ "a.prototype.c;");
+ }
+
+ public void testCrDefinePropertyInvalidPropertyKind()
+ throws Exception {
+ test(
+ "cr.defineProperty(a.b, 'c', cr.PropertyKind.INEXISTENT_KIND);",
+ null, ChromePass.CR_DEFINE_PROPERTY_INVALID_PROPERTY_KIND);
+ }
+
}
« no previous file with comments | « third_party/closure_compiler/runner/src/com/google/javascript/jscomp/ChromePass.java ('k') | ui/webui/resources/js/cr.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698