Skip to content

Commit

Permalink
Merge pull request #17 from KongBorup/dev
Browse files Browse the repository at this point in the history
v0.3.1
  • Loading branch information
avborup authored Jan 21, 2021
2 parents 4b18f38 + c22bba1 commit 6af5c78
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
8 changes: 6 additions & 2 deletions src/commands/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ fn run_tests(
};

if output.status.success() {
let ans_str = ans.trim().replace("\r\n", "\n");
let out_str = stdout.trim().replace("\r\n", "\n");
let ans_str = reformat_ans_str(&ans);
let out_str = reformat_ans_str(&stdout);

if ans_str == out_str {
println!("{}", CHECKBOX);
Expand Down Expand Up @@ -175,3 +175,7 @@ fn run_tests(

Ok(())
}

fn reformat_ans_str(s: &str) -> String {
s.replace("\r\n", "\n").lines().map(str::trim).collect()
}
11 changes: 3 additions & 8 deletions src/lang.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
use crate::StdErr;
use std::env::consts::EXE_EXTENSION;
use std::fmt;
use std::path::PathBuf;
use Language::*;

#[cfg(target_os = "windows")]
const EXEC_EXT: &str = "exe";

#[cfg(not(target_os = "windows"))]
const EXEC_EXT: &str = "";

#[derive(PartialEq, Eq, Hash, Debug, Copy, Clone)]
pub enum Language {
Haskell,
Expand Down Expand Up @@ -75,10 +70,10 @@ impl Language {
.map(|v| v.iter().map(|s| s.to_string()).collect::<Vec<String>>());

let exec_path = match self {
Haskell => path.with_extension(EXEC_EXT),
Haskell => path.with_extension(EXE_EXTENSION),
Java => path.with_extension(""),
Python => path.to_owned(),
Rust => path.with_extension(EXEC_EXT),
Rust => path.with_extension(EXE_EXTENSION),
Unknown => PathBuf::new(),
};

Expand Down

0 comments on commit 6af5c78

Please sign in to comment.