Skip to content

Commit a25c56c

Browse files
PeterCardenaslewis6991
authored andcommitted
test: add context tests for languages with queries
1 parent 059087f commit a25c56c

File tree

13 files changed

+164
-0
lines changed

13 files changed

+164
-0
lines changed

test/lang/test.Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
test: # {{CONTEXT}}
2+
3+
4+
5+
echo "Hello {{CURSOR}}"
6+

test/lang/test.diff

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
diff --git a/src/main.rs b/src/main.rs // {{CONTEXT}}
2+
index 8a23456..9b78901 100644
3+
--- a/src/main.rs
4+
+++ b/src/main.rs
5+
@@ -10,7 +10,7 @@ fn main() { // {{CONTEXT}}
6+
println!("Hello, world!");
7+
8+
// Initialize configuration
9+
- let config = Config::new();
10+
+ let config = Config::new_with_defaults();
11+
12+
let args = std::env::args().collect::<Vec<String>>(); // {{CURSOR}}
13+
14+
@@ -25,6 +25,8 @@ fn main() {
15+
// Process command line arguments
16+
let mut processor = ArgProcessor::new(&args);
17+
processor.process();
18+
+
19+
+ println!("Configuration loaded successfully");
20+
21+
if args.len() > 1 {
22+
println!("Arguments provided: {}", args.len() - 1);
23+
@@ -45,9 +47,7 @@ fn process_file(path: &str) -> Result<(), Error> {
24+
let file = File::open(path)?;
25+
let reader = BufReader::new(file);
26+
27+
- for line in reader.lines() {
28+
- println!("{}", line?);
29+
- }
30+
+ reader.lines().for_each(|line| println!("{}", line.unwrap_or_default()));
31+
32+
Ok(())
33+
}
34+
@@ -78,6 +78,11 @@ impl Config {
35+
}
36+
}
37+
38+
+ pub fn new_with_defaults() -> Self {
39+
+ let mut config = Self::new();
40+
+ config.timeout = Some(30);
41+
+ config
42+
+ }
43+
+
44+
// Other methods...
45+
}
46+

test/lang/test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
class UserAccount { // {{CONTEXT}}
2+
name;
3+
id;
4+
5+
6+
7+
// {{CURSOR}}
8+
constructor(name, id) { // {{CONTEXT}}
9+
this.name = name;
10+
this.id = id;
11+
12+
// {{CURSOR}}
13+
for (let i = 0; i < 3; i++) { // {{CONTEXT}}
14+
console.log("hello");
15+
16+
17+
// {{CURSOR}}
18+
} // {{POPCONTEXT}}
19+
20+
21+
22+
// {{CURSOR}}
23+
}
24+
}

test/lang/test.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{"{{CONTEXT}}":
2+
3+
4+
5+
"{{CURSOR}}"
6+
}

test/lang/test.latex

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
\documentclass{article}
2+
\title{Sample LaTeX Document}
3+
\author{Author Name}
4+
\date{\today}
5+
6+
\begin{document} % {{CONTEXT}}
7+
8+
\maketitle
9+
10+
\section{Introduction} % BUG: should have context
11+
12+
13+
14+
This is a sample section in a LaTeX document. LaTeX is a document preparation system that is widely used for scientific and technical documents.
15+
16+
17+
% {{CURSOR}}
18+
19+
20+
\end{document}
21+

test/lang/test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
def hello(name: str, age: int) -> None: # {{CONTEXT}}
2+
print(f"Hello {name}! You are {age} years old.")
3+
4+
5+
6+
# {{CURSOR}}

test/lang/test.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Test { // {{CONTEXT}}
2+
def hello(name: String, age: Int): Unit = { // {{CONTEXT}}
3+
println(s"Hello $name! You are $age years old.")
4+
5+
6+
7+
// {{CURSOR}}
8+
}
9+
}

test/lang/test.tcl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
proc hello {name age} { # {{CONTEXT}}
2+
puts "Hello $name! You are $age years old."
3+
4+
5+
6+
7+
# {{CURSOR}}
8+
}

test/lang/test.tl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
while true do -- {{CONTEXT}}
2+
print("Hello world!")
3+
4+
5+
6+
-- {{CURSOR}}
7+
end

test/lang/test.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[test] # {{CONTEXT}}
2+
wow = [ # {{CONTEXT}}
3+
4+
5+
6+
"hello", # {{CURSOR}}
7+
]

0 commit comments

Comments
 (0)