Skip to content

Commit

Permalink
fixup(quiz): trim ends for better output matching
Browse files Browse the repository at this point in the history
  • Loading branch information
rootCircle committed Dec 2, 2023
1 parent fa41349 commit e2dc4c0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ lettre = { version = "0.10.4", features = ["tokio1", "tokio1-native-tls"] }
serde = "1.0.189"
tower-http = { version = "0.4.4", features = ["full"] }
http = "0.2.9"
zen = {git = "https://github.com/zenlang-rs/zen-lang.git", branch = "main", version = "^0.2.2"}
zen = {git = "https://github.com/zenlang-rs/zen-lang.git", branch = "main", version = "^0.2.3"}
jsonwebtoken = "9.1.0"
once_cell = "1.18.0"
shuttle-persist = "0.34.1"
Expand Down
5 changes: 3 additions & 2 deletions src/controllers/compile_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use zen::run_program;
#[derive(Deserialize)]
pub struct CodeCompileRequest {
pub code: String,
pub input: String
}
#[derive(Serialize)]
pub struct CodeOutputResponse {
Expand Down Expand Up @@ -32,7 +33,7 @@ pub async fn compile_code(
extract::Json(user): extract::Json<CodeCompileRequest>,
) -> Json<CodeOutputResponse> {
Json(CodeOutputResponse {
output: runnable_code(user.code, ""),
output: runnable_code(user.code, &user.input),
})
}

Expand All @@ -57,7 +58,7 @@ fn match_outputs(code: String, testcases: Vec<Testcase>) -> Vec<Result<bool, Str
let code_instance = runnable_code(code.clone(), &testcase.input);

match code_instance {
Ok(actual_output) => output_vec.push(Ok(actual_output == testcase.expected_output)),
Ok(actual_output) => output_vec.push(Ok(actual_output.trim_end() == testcase.expected_output)),
Err(err) => output_vec.push(Err(err)),
}
}
Expand Down

0 comments on commit e2dc4c0

Please sign in to comment.