Skip to content

Commit

Permalink
More work on tests. 6 down. 12 to go.
Browse files Browse the repository at this point in the history
Signed-off-by: Hal Gentz <[email protected]>
  • Loading branch information
goddessfreya committed Oct 28, 2019
1 parent 3573344 commit 2d9e2ce
Show file tree
Hide file tree
Showing 5 changed files with 744 additions and 190 deletions.
43 changes: 42 additions & 1 deletion gcpproc/src/common.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![macro_escape]
//! Common files for preprocessor.
/// All the parameters the preprocessor cares about.
Expand Down Expand Up @@ -126,7 +127,11 @@ pub struct Issue {
}

impl Issue {
pub fn new(loc: Option<Location>, itype: IssueType, desc: IssueDesc) -> Self {
pub fn new(
loc: Option<Location>,
itype: IssueType,
desc: IssueDesc,
) -> Self {
Issue { loc, itype, desc }
}
}
Expand Down Expand Up @@ -210,3 +215,39 @@ impl Version {

CVersionCmp!(ver_ne, !=);
}

// Formated assert_eq
macro_rules! fassert_eq {
($left:expr, $right:expr) => ({
match (&$left, &$right) {
(left_val, right_val) => {
if !(*left_val == *right_val) {
// The reborrows below are intentional. Without them, the stack slot for the
// borrow is initialized even before the values are compared, leading to a
// noticeable slow down.
panic!(r#"assertion failed: `(left == right)`
left: `{:#?}`,
right: `{:#?}`"#, &*left_val, &*right_val)
}
}
}
});
($left:expr, $right:expr,) => ({
fassert_eq!($left, $right)
});
($left:expr, $right:expr, $($arg:tt)+) => ({
match (&($left), &($right)) {
(left_val, right_val) => {
if !(*left_val == *right_val) {
// The reborrows below are intentional. Without them, the stack slot for the
// borrow is initialized even before the values are compared, leading to a
// noticeable slow down.
panic!(r#"assertion failed: `(left == right)`
left: `{:#?}`,
right: `{:#?}`: {}"#, &*left_val, &*right_val,
format_args!($($arg)+))
}
}
}
});
}
4 changes: 0 additions & 4 deletions gcpproc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ n\"
dbg!(&ret);
println!("{}", ret.new_file);

// Just a guess.
let num_tokens_guess = ret.num_spaces * 4;
dbg!(num_tokens_guess);

enum ActiveLexer {}

let mut lexer = SourceLex::lexer(&file as &str);
Expand Down
Loading

0 comments on commit 2d9e2ce

Please sign in to comment.