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

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

Issue 557633002: Add public API generation with cr.makePublic() and handle it in compiler pass (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@H_options_errors_3
Patch Set: report missing declarations Created 6 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package com.google.javascript.jscomp; 5 package com.google.javascript.jscomp;
6 6
7 /** 7 /**
8 * Tests {@link ChromePass}. 8 * Tests {@link ChromePass}.
9 */ 9 */
10 public class ChromePassTest extends CompilerTestCase { 10 public class ChromePassTest extends CompilerTestCase {
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 "cr.ui = cr.ui || {};\n" + 356 "cr.ui = cr.ui || {};\n" +
357 "cr.define('cr.ui', function() {\n" + 357 "cr.define('cr.ui', function() {\n" +
358 " return {};\n" + 358 " return {};\n" +
359 "});"); 359 "});");
360 } 360 }
361 361
362 public void testCrExportPathInvalidNumberOfArguments() throws Exception { 362 public void testCrExportPathInvalidNumberOfArguments() throws Exception {
363 test("cr.exportPath();", null, ChromePass.CR_EXPORT_PATH_WRONG_NUMBER_OF _ARGUMENTS); 363 test("cr.exportPath();", null, ChromePass.CR_EXPORT_PATH_WRONG_NUMBER_OF _ARGUMENTS);
364 } 364 }
365 365
366 public void testCrMakePublicWorksOnOneMethod() throws Exception {
367 test(
368 "/** @constructor */\n" +
369 "Class = function() {};\n" +
370 "\n" +
371 "Class.prototype = {\n" +
372 " /** @return {number} */\n" +
373 " method_: function() { return 42; }\n" +
374 "};\n" +
375 "\n" +
376 "cr.makePublic(Class, ['method']);",
377 "/** @constructor */\n" +
378 "Class = function() {};\n" +
379 "\n" +
380 "Class.prototype = {\n" +
381 " /** @return {number} */\n" +
382 " method_: function() { return 42; }\n" +
383 "};\n" +
384 "\n" +
385 "/** @return {number} */\n" +
386 "Class.method;\n" +
387 "\n" +
388 "cr.makePublic(Class, ['method']);");
389 }
390
391 public void testCrMakePublicWorksOnTwoMethods() throws Exception {
392 test(
393 "/** @constructor */\n" +
394 "Class = function() {}\n" +
395 "\n" +
396 "Class.prototype = {\n" +
397 " /** @return {number} */\n" +
398 " m1_: function() { return 42; },\n" +
399 "\n" +
400 " /** @return {string} */\n" +
401 " m2_: function() { return ''; }\n" +
402 "};\n" +
403 "\n" +
404 "cr.makePublic(Class, ['m1', 'm2']);",
405 "/** @constructor */\n" +
406 "Class = function() {}\n" +
407 "\n" +
408 "Class.prototype = {\n" +
409 " /** @return {number} */\n" +
410 " m1_: function() { return 42; },\n" +
411 "\n" +
412 " /** @return {string} */\n" +
413 " m2_: function() { return ''; }\n" +
414 "}\n" +
415 "\n" +
416 "/** @return {number} */\n" +
417 "Class.m1;\n" +
418 "\n" +
419 "/** @return {string} */\n" +
420 "Class.m2;\n" +
421 "\n" +
422 "cr.makePublic(Class, ['m1', 'm2']);");
423 }
424
425 public void testCrMakePublicRequiresMethodsToHaveJSDoc() throws Exception {
426 test("/** @constructor */\n" +
427 "Class = function() {}\n" +
428 "\n" +
429 "Class.prototype = {\n" +
430 " method_: function() {}\n" +
431 "}\n" +
432 "\n" +
433 "cr.makePublic(Class, ['method']);", null, ChromePass.CR_MAKE_PU BLIC_HAS_NO_JSDOC);
434 }
435
436 public void testCrMakePublicDoesNothingWithMethodsNotInAPI() throws Exceptio n {
437 test("/** @constructor */\n" +
438 "Class = function() {}\n" +
439 "\n" +
440 "Class.prototype = {\n" +
441 " method_: function() {}\n" +
442 "}\n" +
443 "\n" +
444 "cr.makePublic(Class, []);",
445 "/** @constructor */\n" +
446 "Class = function() {}\n" +
447 "\n" +
448 "Class.prototype = {\n" +
449 " method_: function() {}\n" +
450 "}\n" +
451 "\n" +
452 "cr.makePublic(Class, []);");
453 }
454
455 public void testCrMakePublicRequiresExportedMethodToBeDeclared() throws Exce ption {
456 test("/** @constructor */\n" +
457 "Class = function() {}\n" +
458 "\n" +
459 "Class.prototype = {\n" +
460 "}\n" +
461 "\n" +
462 "cr.makePublic(Class, ['method']);", null,
463 ChromePass.CR_MAKE_PUBLIC_MISSED_DECLARATION);
464 }
465
366 } 466 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698