1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
use codebook::queries::LanguageType;
use super::utils::assert_spelling_at;
#[test]
fn test_java_location() {
let sample_text = r#"
// Singl-line comment
/* Blck comment */
interface ExamplInterface {
void doSomethng();
}
enum Statuss { ACTIV }
public class SoemJavaDemo implements ExamplInterface {
String messag = "Hello";
public void doSomethng(String smth) {
System.out.println("Doing " + smth + "...");
}
public static void main(String[] args) {
try {
int x = 1 / 0;
} catch (ArithmeticException errorr) {
System.out.println("Caught: " + errorr);
some.recoveryMthod();
}
}
}"#;
// Keywords and method-call references (`recoveryMthod`) are not
// spell-checked; exact set equality guards that.
assert_spelling_at(
LanguageType::Java,
sample_text,
&[
("Singl", &[0]),
("Blck", &[0]),
// Flagged at the interface definition; the `implements` reference
// is not.
("Exampl", &[0]),
// Flagged at both method definitions (interface and class).
("Somethng", &[0, 1]),
("Statuss", &[0]),
("ACTIV", &[0]),
("Soem", &[0]),
("messag", &[0]),
// Flagged at the parameter definition; the usage in the string
// concatenation is not.
("smth", &[0]),
// Flagged at the catch parameter; the usage in println is not.
("errorr", &[0]),
],
);
}