-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract normal specs on abstract trait methods (#106)
* Add test case. * Preliminary refactor. * Generate unimplemented body and specs with macro. * Annotate pseudo-abstract methods. * Pick up the flag "is_abstract". * Conditionally compile macro implementation.
- Loading branch information
1 parent
a968c81
commit 24dad76
Showing
14 changed files
with
299 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[build] | ||
rustflags = ["--cfg", "stainless"] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
extern crate stainless; | ||
use stainless::*; | ||
|
||
trait SpecsNotLaws { | ||
#[post(ret > 0)] | ||
fn always_positive(&self) -> i32; | ||
|
||
#[pre(b)] | ||
fn always_call_true(b: bool) { | ||
let _a = 1; | ||
} | ||
} | ||
|
||
impl SpecsNotLaws for u32 { | ||
fn always_positive(&self) -> i32 { | ||
123 | ||
} | ||
|
||
fn always_call_true(_b: bool) {} | ||
} | ||
|
||
pub fn main() { | ||
let number: u32 = 465; | ||
u32::always_call_true(true); | ||
assert!(number.always_positive() > 0) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.