Skip to content

Commit

Permalink
tests(typescript): Add e2e tests for comments
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpovel committed Nov 27, 2023
1 parent f38136c commit 7ab5dff
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tests/langs/csharp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use super::{get_input_output, nuke_target};
#[rstest]
#[case("comments.cs", CSharpQuery::Premade(PremadeCSharpQuery::Comments))]
#[case("strings.cs", CSharpQuery::Premade(PremadeCSharpQuery::Strings))]
fn test_csharp(#[case] file: &str, #[case] query: CSharpQuery) {
fn test_csharp_nuke(#[case] file: &str, #[case] query: CSharpQuery) {
let lang = CSharp::new(query);

let (input, output) = get_input_output("csharp", file);
Expand Down
1 change: 1 addition & 0 deletions tests/langs/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
mod csharp;
mod python;
mod typescript;

use std::{fs::read_to_string, path::Path};

Expand Down
2 changes: 1 addition & 1 deletion tests/langs/python/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use super::{get_input_output, nuke_target};
"function-calls.py",
PythonQuery::Premade(PremadePythonQuery::FunctionCalls)
)]
fn test_python(#[case] file: &str, #[case] query: PythonQuery) {
fn test_python_nuke(#[case] file: &str, #[case] query: PythonQuery) {
let lang = Python::new(query);

let (input, output) = get_input_output("python", file);
Expand Down
22 changes: 22 additions & 0 deletions tests/langs/typescript/in/comments.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// This is a __T__single-line comment
let singleLineComment: string = 'This uses a single-line__T__ comment';

/*
This is a multi-line comment
It can span multiple__T__ lines
*/
let multiLineComment: string = 'This uses a multi-line__T__ comment';

/**
* Adds two numbers.__T__
* @param a The first number.
* @param b The second__T__ number.
* @return The sum of a and b.
*/
function add(a: number, b__T__: number): number {
return a + b__T__;
}

console.log(singleLineComment);
console.log(multiLineComment);
console.log(`add(5, 3)__T__ = ${add(5, 3)}`);
22 changes: 22 additions & 0 deletions tests/langs/typescript/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use rstest::rstest;
use srgn::scoping::langs::typescript::{PremadeTypeScriptQuery, TypeScript, TypeScriptQuery};

use super::{get_input_output, nuke_target};

#[rstest]
#[case(
"comments.ts",
TypeScriptQuery::Premade(PremadeTypeScriptQuery::Comments)
)]
// #[case(
// "strings.cs",
// TypeScriptQuery::Premade(PremadeTypeScriptQuery::Strings)
// )]
fn test_typescript_nuke(#[case] file: &str, #[case] query: TypeScriptQuery) {
let lang = TypeScript::new(query);

let (input, output) = get_input_output("typescript", file);
let result = nuke_target(&input, &lang);

assert_eq!(result, output);
}
22 changes: 22 additions & 0 deletions tests/langs/typescript/out/comments.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// This is a single-line comment
let singleLineComment: string = 'This uses a single-line__T__ comment';

/*
This is a multi-line comment
It can span multiple lines
*/
let multiLineComment: string = 'This uses a multi-line__T__ comment';

/**
* Adds two numbers.
* @param a The first number.
* @param b The second number.
* @return The sum of a and b.
*/
function add(a: number, b__T__: number): number {
return a + b__T__;
}

console.log(singleLineComment);
console.log(multiLineComment);
console.log(`add(5, 3)__T__ = ${add(5, 3)}`);

0 comments on commit 7ab5dff

Please sign in to comment.