ppTests undef
This commit is contained in:
parent
bf6e5688aa
commit
ae43678b9e
@ -1618,4 +1618,21 @@ mod tests {
|
|||||||
testfile_contents("unconnected_drive.sv")
|
testfile_contents("unconnected_drive.sv")
|
||||||
);
|
);
|
||||||
} // }}}
|
} // }}}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn undef() { // {{{
|
||||||
|
let include_paths = [testfile_path("")];
|
||||||
|
let (ret, _) = preprocess(
|
||||||
|
testfile_path("undef.sv"),
|
||||||
|
&HashMap::new(),
|
||||||
|
&include_paths,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
ret.text(),
|
||||||
|
testfile_contents("expected/undef.sv")
|
||||||
|
);
|
||||||
|
} // }}}
|
||||||
}
|
}
|
||||||
|
20
sv-parser-pp/testcases/expected/undef.sv
Normal file
20
sv-parser-pp/testcases/expected/undef.sv
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// IEEE1800-2017 Clause 22.5.2
|
||||||
|
// The directive `undef shall undefine the specified text macro if previously
|
||||||
|
// defined by a `define compiler directive within the compilation unit. An
|
||||||
|
// attempt to undefine a text macro that was not previously defined using a
|
||||||
|
// `define compiler directive can issue a warning.
|
||||||
|
`undef FOO
|
||||||
|
`undef FOO// Comment
|
||||||
|
`undef FOO // Comment
|
||||||
|
|
||||||
|
`define FOO foo
|
||||||
|
// AAA
|
||||||
|
// This block SHOULD be emitted from the preprocessor.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
`undef FOO
|
||||||
|
|
||||||
|
// BBB
|
||||||
|
// This block SHOULD be emitted from the preprocessor.
|
||||||
|
|
28
sv-parser-pp/testcases/undef.sv
Normal file
28
sv-parser-pp/testcases/undef.sv
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// IEEE1800-2017 Clause 22.5.2
|
||||||
|
// The directive `undef shall undefine the specified text macro if previously
|
||||||
|
// defined by a `define compiler directive within the compilation unit. An
|
||||||
|
// attempt to undefine a text macro that was not previously defined using a
|
||||||
|
// `define compiler directive can issue a warning.
|
||||||
|
`undef FOO
|
||||||
|
`undef FOO// Comment
|
||||||
|
`undef FOO // Comment
|
||||||
|
|
||||||
|
`define FOO foo
|
||||||
|
`ifdef FOO
|
||||||
|
// AAA
|
||||||
|
// This block SHOULD be emitted from the preprocessor.
|
||||||
|
`endif
|
||||||
|
`ifndef FOO
|
||||||
|
// AAA
|
||||||
|
// This block should NOT be emitted from the preprocessor.
|
||||||
|
`endif
|
||||||
|
|
||||||
|
`undef FOO
|
||||||
|
`ifdef FOO
|
||||||
|
// BBB
|
||||||
|
// This block should NOT be emitted from the preprocessor.
|
||||||
|
`endif
|
||||||
|
`ifndef FOO
|
||||||
|
// BBB
|
||||||
|
// This block SHOULD be emitted from the preprocessor.
|
||||||
|
`endif
|
Loading…
x
Reference in New Issue
Block a user