mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-28 16:25:00 +00:00
refactor: move test code samples to fixture files
This commit is contained in:
parent
8c218e9edc
commit
4580fac6fa
1 changed files with 6 additions and 84 deletions
|
@ -380,62 +380,17 @@ public class Test implements Greeting {
|
||||||
),
|
),
|
||||||
"javascript": (
|
"javascript": (
|
||||||
"test.js",
|
"test.js",
|
||||||
"""// Class definition
|
"", # Now reads from fixture file
|
||||||
class Person {
|
|
||||||
constructor(name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
sayHello() {
|
|
||||||
return `Hello, ${this.name}!`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function declaration
|
|
||||||
function greet(person) {
|
|
||||||
return person.sayHello();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Variables and constants
|
|
||||||
const DEFAULT_NAME = 'World';
|
|
||||||
let currentPerson = new Person(DEFAULT_NAME);
|
|
||||||
|
|
||||||
// Export for use in other modules
|
|
||||||
module.exports = {
|
|
||||||
Person,
|
|
||||||
greet,
|
|
||||||
DEFAULT_NAME
|
|
||||||
};
|
|
||||||
""",
|
|
||||||
"Person", # Key symbol to check
|
"Person", # Key symbol to check
|
||||||
),
|
),
|
||||||
"ocaml": (
|
"ocaml": (
|
||||||
"test.ml",
|
"test.ml",
|
||||||
"""(* Module definition *)
|
"", # Now reads from fixture file
|
||||||
module Greeter = struct
|
|
||||||
type person = {
|
|
||||||
name: string;
|
|
||||||
age: int
|
|
||||||
}
|
|
||||||
|
|
||||||
let create_person name age =
|
|
||||||
{name; age}
|
|
||||||
|
|
||||||
let greet person =
|
|
||||||
Printf.printf "Hello, %s! You are %d years old.\\n"
|
|
||||||
person.name person.age
|
|
||||||
end
|
|
||||||
|
|
||||||
(* Outside the module *)
|
|
||||||
let () =
|
|
||||||
let person = Greeter.create_person "Alice" 30 in
|
|
||||||
Greeter.greet person
|
|
||||||
""",
|
|
||||||
"Greeter", # Key symbol to check
|
"Greeter", # Key symbol to check
|
||||||
),
|
),
|
||||||
"php": (
|
"php": (
|
||||||
"test.php",
|
"test.php",
|
||||||
'<?php\nfunction greet($name) {\n echo "Hello, $name!";\n}\n?>\n',
|
"", # Now reads from fixture file
|
||||||
"greet", # Key symbol to check
|
"greet", # Key symbol to check
|
||||||
),
|
),
|
||||||
"python": (
|
"python": (
|
||||||
|
@ -445,50 +400,17 @@ let () =
|
||||||
),
|
),
|
||||||
"ql": (
|
"ql": (
|
||||||
"test.ql",
|
"test.ql",
|
||||||
'predicate greet(string name) {\n name = "World"\n}\n',
|
"", # Now reads from fixture file
|
||||||
"greet", # Key symbol to check
|
"greet", # Key symbol to check
|
||||||
),
|
),
|
||||||
"ruby": (
|
"ruby": (
|
||||||
"test.rb",
|
"test.rb",
|
||||||
'def greet(name)\n puts "Hello, #{name}!"\nend\n',
|
"", # Now reads from fixture file
|
||||||
"greet", # Key symbol to check
|
"greet", # Key symbol to check
|
||||||
),
|
),
|
||||||
"rust": (
|
"rust": (
|
||||||
"test.rs",
|
"test.rs",
|
||||||
"""// Define a trait
|
"", # Now reads from fixture file
|
||||||
trait Greeting {
|
|
||||||
fn greet(&self) -> String;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Define a struct
|
|
||||||
struct Person {
|
|
||||||
name: String,
|
|
||||||
age: u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
// Implement the trait for Person
|
|
||||||
impl Greeting for Person {
|
|
||||||
fn greet(&self) -> String {
|
|
||||||
format!("Hello, {}! You are {} years old.", self.name, self.age)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Implementation block for Person
|
|
||||||
impl Person {
|
|
||||||
fn new(name: String, age: u32) -> Self {
|
|
||||||
Person { name, age }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Constants
|
|
||||||
const DEFAULT_NAME: &str = "World";
|
|
||||||
const MAX_AGE: u32 = 150;
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let person = Person::new(DEFAULT_NAME.to_string(), 30);
|
|
||||||
println!("{}", person.greet());
|
|
||||||
}
|
|
||||||
""",
|
|
||||||
"Person", # Key symbol to check
|
"Person", # Key symbol to check
|
||||||
),
|
),
|
||||||
"typescript": (
|
"typescript": (
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue