Skip to content

Commit

Permalink
chore: update chapi to 2.2.3 for fix testing annotation position issue
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Jan 4, 2024
1 parent b9af199 commit 28fc827
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ clikt = "4.2.1"

chocolate-factory = "0.4.5"

chapi = "2.2.2"
chapi = "2.2.3"
archguard = "2.1.2"
codedb = "0.1.3"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,8 @@ fun CodeContainer.buildSourceCode(codeLines: List<String>) {
val position = it.Position
if (it.Annotations.isNotEmpty()) {
val annotationPos = it.Annotations.first().Position
if (annotationPos.StartLine != 0) {
position.StartLine = annotationPos.StartLine
position.StartLinePosition = annotationPos.StartLinePosition
} else {
position.StartLine -= 2
}
position.StartLine = annotationPos.StartLine
position.StartLinePosition = annotationPos.StartLinePosition
}

it.Content = CodeDataStructUtil.contentByPosition(codeLines, it.Position)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class RustTestCodeServiceTest {
assert_eq!(embedding.len(), 128);
}
}
""".trimIndent()
""".trimIndent()

val container = RustAnalyser().analysis(testCode, "lib.rs")
container.buildSourceCode(testCode.lines())
Expand Down Expand Up @@ -75,14 +75,16 @@ class RustTestCodeServiceTest {
let result = Semantic::init_semantic(model, tokenizer_data)?;
Ok(Arc::new(result))
}""", build[0].underTestCode)
assertEquals("fn test_init_semantic() {\n" +
" let model = std::fs::read(\"../model/model.onnx\").unwrap();\n" +
" let tokenizer_data = std::fs::read(\"../model/tokenizer.json\").unwrap();\n" +
"\n" +
" let semantic = init_semantic(model, tokenizer_data).unwrap();\n" +
" let embedding = semantic.embed(\"hello world\").unwrap();\n" +
" assert_eq!(embedding.len(), 128);\n" +
"}", build[0].generatedCode)
assertEquals("""#[test]
#[cfg_attr(feature = "ci", ignore)]
fn test_init_semantic() {
let model = std::fs::read("../model/model.onnx").unwrap();
let tokenizer_data = std::fs::read("../model/tokenizer.json").unwrap();
let semantic = init_semantic(model, tokenizer_data).unwrap();
let embedding = semantic.embed("hello world").unwrap();
assert_eq!(embedding.len(), 128);
}""", build[0].generatedCode)
}

}

0 comments on commit 28fc827

Please sign in to comment.