Skip to content

Commit

Permalink
Support Ada
Browse files Browse the repository at this point in the history
  • Loading branch information
hjaremko committed Jul 24, 2021
1 parent f17b391 commit dcc83e0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/baca/details/language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub enum Language {
Bash = 10,
CppWithFileSupport = 12,
// C = ?,
// Ada = ?,
Ada = 9,
}

impl Language {
Expand All @@ -28,6 +28,7 @@ impl ToString for Language {
Language::Java => "Java",
Language::Bash => "Bash",
Language::CppWithFileSupport => "C++ with file support",
Language::Ada => "Ada",
Language::Unsupported => "Unsupported language",
}
.to_string()
Expand All @@ -43,6 +44,7 @@ impl FromStr for Language {
"java" => Language::Java,
"bash" => Language::Bash,
"c++ z obsluga plikow" => Language::CppWithFileSupport,
"ada" => Language::Ada,
lang => return Err(Self::Err::UnsupportedLanguage(lang.to_string())),
};

Expand All @@ -64,7 +66,7 @@ mod tests {
Language::from_str("C++ z obsluga plikow").unwrap(),
Language::CppWithFileSupport
);
assert!(Language::from_str("Ada").is_err());
assert_eq!(Language::from_str("Ada").unwrap(), Language::Ada);
assert!(Language::from_str("C").is_err());
}

Expand All @@ -78,6 +80,7 @@ mod tests {
Language::CppWithFileSupport.to_string(),
"C++ with file support"
);
assert_eq!(Language::Ada.to_string(), "Ada");
}

#[test]
Expand Down Expand Up @@ -107,5 +110,6 @@ mod tests {
assert_eq!(Language::Java.code(), "4");
assert_eq!(Language::Bash.code(), "10");
assert_eq!(Language::CppWithFileSupport.code(), "12");
assert_eq!(Language::Ada.code(), "9");
}
}

0 comments on commit dcc83e0

Please sign in to comment.