@Test
  public void toleratesWindowsLineBreaks() {
    jsHint.configure(new JsonObject().add("white", false));
    jsHint.check("var x = 1;\r\nvar y = 2;\r\nvar z = 23 == null;", handler);

    assertEquals("3.11", getPositionFromProblem(0));
  }
  @Test
  public void positionIsCorrectWithLeadingSpace() {
    jsHint.configure(new JsonObject().add("white", false));
    jsHint.check(" var x = 23 == null;", handler);

    assertEquals("1.12", getPositionFromProblem(0));
  }
  @Test
  public void positionIsCorrectWithMultipleTabs() {
    jsHint.configure(new JsonObject().add("white", false));
    jsHint.check("\tvar x\t= 23 == null;", handler);

    assertEquals("1.12", getPositionFromProblem(0));
  }
  @Test
  public void eqnull_withEmptyConfig() {
    jsHint.configure(new JsonObject());

    jsHint.check("var x = 23 == null;", handler);

    assertEquals("1.11:Use '===' to compare with 'null'", getAllProblems());
  }
  @Test
  public void undefinedVariable_withoutPredefInConfig_fails() {
    jsHint.configure(new JsonObject().add("undef", true));

    jsHint.check("foo = {};", handler);

    assertEquals("1.0:'foo' is not defined", getAllProblems());
  }
  @Test
  public void eqnull_withEqnullInConfig() {
    jsHint.configure(new JsonObject().add("eqnull", true));

    jsHint.check("var f = x == null ? null : x + 1;", handler);

    assertEquals("", getAllProblems());
  }
  @Test
  public void undefinedVariable_withReadOnlyPredefInConfig_fails() {
    JsonObject globals = new JsonObject().add("foo", false);
    jsHint.configure(new JsonObject().add("undef", true).add("globals", globals));

    jsHint.check("foo = {};", handler);

    assertEquals("1.0:Read only", getAllProblems());
  }
  @Test
  public void undefinedVariable_withPredefInConfig_succeeds() {
    JsonObject globals = new JsonObject().add("foo", true);
    jsHint.configure(new JsonObject().add("undef", true).add("globals", globals));

    jsHint.check("foo = {};", handler);

    assertEquals("", getAllProblems());
  }
  @Test
  public void extraComma() {
    JsonObject config = new JsonObject();
    if (versionGreaterThan("2.0.0")) {
      config.add("es3", true);
    }
    jsHint.configure(config);

    jsHint.check("var o = { x: 1, y: 2, z: 3, };", handler);

    assertThat(getAllProblems(), startsWith("1.26:Extra comma"));
  }
 private void loadJsHint() throws IOException {
   ClassLoader classLoader = getClass().getClassLoader();
   String resource = "com/jshint/jshint-" + version + ".js";
   InputStream stream = classLoader.getResourceAsStream(resource);
   if (stream == null) {
     throw new IllegalArgumentException("JSHint resource not found: " + resource);
   }
   try {
     jsHint.load(stream);
   } finally {
     stream.close();
   }
 }
  @Test
  public void problemLineIs_1_Relative() {
    jsHint.check("#", handler);

    assertEquals(1, problems.get(0).getLine());
  }
  @Test
  public void noProblemsForValidCode() {
    jsHint.check("var a = 23;", handler);

    assertTrue(problems.isEmpty());
  }
  @Test
  public void eqnull_withoutConfig() {
    jsHint.check("var x = 23 == null;", handler);

    assertEquals("1.11:Use '===' to compare with 'null'", getAllProblems());
  }
  @Test
  public void problemCharacterIs_0_Relative() {
    jsHint.check("#", handler);

    assertEquals(0, problems.get(0).getCharacter());
  }
  @Test
  public void positionIsCorrect() {
    jsHint.check("var x = 23 == null;", handler);

    assertEquals("1.11", getPositionFromProblem(0));
  }
  @Test
  public void cproblemMessageIsNotEmpty() {
    jsHint.check("#", handler);

    assertTrue(problems.get(0).getMessage().length() > 0);
  }
  @Test
  public void undefinedVariable_withoutConfig_succeeds() {
    jsHint.check("foo = {};", handler);

    assertEquals("", getAllProblems());
  }