<commit_before>/*
 * Copyright 2014 The Closure Compiler Authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.javascript.jscomp.lint;

import com.google.javascript.jscomp.CheckLevel;
import com.google.javascript.jscomp.Compiler;
import com.google.javascript.jscomp.CompilerOptions;
import com.google.javascript.jscomp.CompilerPass;
import com.google.javascript.jscomp.CompilerTestCase;
import com.google.javascript.jscomp.DiagnosticGroups;

/**
 * Test case for {@link CheckInterfaces}.
 */
public final class CheckInterfacesTest extends CompilerTestCase {
  @Override
  protected CompilerPass getProcessor(Compiler compiler) {
    return new CheckInterfaces(compiler);
  }

  @Override
  protected CompilerOptions getOptions(CompilerOptions options) {
    super.getOptions(options);
    options.setWarningLevel(DiagnosticGroups.LINT_CHECKS, CheckLevel.WARNING);
    return options;
  }

  protected void setUp() throws Exception {
    super.setUp();
    enableTypeCheck();
  }

  public void testInterfaceArgs() throws Exception {
    testSame("/** @interface */ function A(x) {}",
        CheckInterfaces.INTERFACE_SHOULD_NOT_TAKE_ARGS);

    testSame(
        LINE_JOINER.join(
            "var ns = {};\n", "/** @interface */\n", "ns.SomeInterface = function(x) {};"),
        CheckInterfaces.INTERFACE_SHOULD_NOT_TAKE_ARGS);
  }

  public void testInterfaceNotEmpty() {
    testSame("/** @interface */ function A() { this.foo; }",
        CheckInterfaces.INTERFACE_FUNCTION_NOT_EMPTY);

    testSame(
        LINE_JOINER.join(
            "var ns = {};\n",
            "/** @interface */\n",
            "ns.SomeInterface = function() { this.foo; };"),
        CheckInterfaces.INTERFACE_FUNCTION_NOT_EMPTY);
  }
}<commit_msg>Removing TypeCheck enabling from CheckInterfacesTest of the LINTCHECKS pass-- should be turned on after transpilation. Part of verification/adding of ES6 module compatibility to compiler.<commit_after>/*
 * Copyright 2014 The Closure Compiler Authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.javascript.jscomp.lint;

import com.google.javascript.jscomp.CheckLevel;
import com.google.javascript.jscomp.Compiler;
import com.google.javascript.jscomp.CompilerOptions;
import com.google.javascript.jscomp.CompilerPass;
import com.google.javascript.jscomp.CompilerTestCase;
import com.google.javascript.jscomp.DiagnosticGroups;

/**
 * Test case for {@link CheckInterfaces}.
 */
public final class CheckInterfacesTest extends CompilerTestCase {
  @Override
  protected CompilerPass getProcessor(Compiler compiler) {
    return new CheckInterfaces(compiler);
  }

  @Override
  protected CompilerOptions getOptions(CompilerOptions options) {
    super.getOptions(options);
    options.setWarningLevel(DiagnosticGroups.LINT_CHECKS, CheckLevel.WARNING);
    return options;
  }

  public void testInterfaceArgs() throws Exception {
    testSame("/** @interface */ function A(x) {}",
        CheckInterfaces.INTERFACE_SHOULD_NOT_TAKE_ARGS);

    testSame(
        LINE_JOINER.join(
            "var ns = {};\n", "/** @interface */\n", "ns.SomeInterface = function(x) {};"),
        CheckInterfaces.INTERFACE_SHOULD_NOT_TAKE_ARGS);
  }

  public void testInterfaceArgs_withES6Modules() throws Exception {
    testSame(
        "export /** @interface */ function A(x) {}",
        CheckInterfaces.INTERFACE_SHOULD_NOT_TAKE_ARGS);
  }

  public void testInterfaceNotEmpty() {
    testSame("/** @interface */ function A() { this.foo; }",
        CheckInterfaces.INTERFACE_FUNCTION_NOT_EMPTY);

    testSame(
        LINE_JOINER.join(
            "var ns = {};\n",
            "/** @interface */\n",
            "ns.SomeInterface = function() { this.foo; };"),
        CheckInterfaces.INTERFACE_FUNCTION_NOT_EMPTY);
  }

  public void testInterfaceNotEmpty_withES6Modules() {
    testSame(
        "export /** @interface */ function A() { this.foo; }",
        CheckInterfaces.INTERFACE_FUNCTION_NOT_EMPTY);
  }
}
{'fraction_non_alphanumeric': 0.10503194888178914, 'fraction_numerical': 0.0037939297124600637, 'mean_word_length': 3.7568850902184234, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5628224', 'n_tokens_mistral': 1411, 'n_tokens_neox': 1380, 'n_words': 387}