-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
916 additions
and
714 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
#![feature(imported_main)] | ||
pub use sweet::*; | ||
#[path = "./mod.rs"] | ||
mod tests; |
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
#![feature(imported_main)] | ||
#![allow( | ||
dead_code, | ||
unused_mut, | ||
|
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
#![feature(imported_main)] | ||
pub use sweet::*; | ||
#[path = "./mod.rs"] | ||
mod tests; |
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
#![feature(imported_main)] | ||
#[path = "./mod.rs"] | ||
mod tests; | ||
pub use sweet::*; |
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
#![feature(imported_main)] | ||
pub use sweet::*; | ||
#[path = "./mod.rs"] | ||
mod tests; |
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
#![feature(imported_main)] | ||
#![allow( | ||
dead_code, | ||
unused_mut, | ||
|
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
#![feature(imported_main)] | ||
#![cfg(target_arch = "wasm32")] | ||
pub use sweet::*; | ||
// #[cfg(target_arch = "wasm32")] | ||
|
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
#![feature(imported_main)] | ||
pub use sweet::*; | ||
|
||
async fn foo() {} | ||
|
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
#![feature(imported_main)] | ||
pub use sweet::*; | ||
|
||
#[sweet_test] | ||
|
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 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 |
---|---|---|
@@ -1,62 +1,62 @@ | ||
use anyhow::Error; | ||
use anyhow::Result; | ||
use sweet::test_case::*; | ||
use sweet::*; | ||
|
||
|
||
/* | ||
Backtrace depth testing is hard. There are normaly three function layers of abstraction: | ||
1. declarative ie to_be | ||
2. assertion ie assert_equal | ||
3. error ie to_error | ||
*/ | ||
|
||
fn declarative_level(err: Error) -> Result<()> { | ||
expect(err.to_string().as_str()).to_contain("backtrace_test.rs") | ||
} | ||
|
||
fn assertion_level(err: Error) -> Result<()> { | ||
expect(err.to_string().as_str()).not().to_contain(".rs") | ||
} | ||
|
||
fn error_level(err: Error) -> Result<()> { | ||
expect(err.to_string().as_str()).not().to_contain(".rs") | ||
// expect(err.to_string().as_str()).to_contain("local_pool.rs") | ||
// expect(err.to_string().as_str()).to_contain("catch_unwind.rs") | ||
} | ||
|
||
sweet! { | ||
|
||
test "file context" { | ||
let ctx = file_context(); | ||
expect(ctx.as_str()).to_contain("let ctx = backtracer::file_context();")?; | ||
// expect(false).to_be_true()?; | ||
} | ||
|
||
test "level 1: declarative"{ | ||
let result = expect(true).to_be(false); | ||
declarative_level(result.unwrap_err())?; | ||
} | ||
|
||
test "level 2: assertion"{ | ||
let result = expect(true).assert_equal(false); | ||
assertion_level(result.unwrap_err())?; | ||
let result = expect(true).assert_correct(false,&false); | ||
assertion_level(result.unwrap_err())?; | ||
let result = expect(true).assert_correct_with_received(false,&false,&true); | ||
assertion_level(result.unwrap_err())?; | ||
} | ||
|
||
test "level 3: error"{ | ||
let err = expect(true).to_error(&false); | ||
error_level(err)?; | ||
let err = expect(true).to_error_with_received(&false,&true); | ||
error_level(err)?; | ||
let err = expect(true).to_error_with_backtrace(&false,0); | ||
error_level(err)?; | ||
|
||
// dont think this one is effective | ||
// let err = expect(true).to_error_with_received_and_backtrace(&false,&true,0); | ||
// assertion_level(err)?; | ||
} | ||
} | ||
// use anyhow::Error; | ||
// use anyhow::Result; | ||
// use sweet::test_case::*; | ||
// use sweet::*; | ||
|
||
|
||
// /* | ||
// Backtrace depth testing is hard. There are normaly three function layers of abstraction: | ||
// 1. declarative ie to_be | ||
// 2. assertion ie assert_equal | ||
// 3. error ie to_error | ||
// */ | ||
|
||
// fn declarative_level(err: Error) -> Result<()> { | ||
// expect(err.to_string().as_str()).to_contain("backtrace_test.rs") | ||
// } | ||
|
||
// fn assertion_level(err: Error) -> Result<()> { | ||
// expect(err.to_string().as_str()).not().to_contain(".rs") | ||
// } | ||
|
||
// fn error_level(err: Error) -> Result<()> { | ||
// expect(err.to_string().as_str()).not().to_contain(".rs") | ||
// // expect(err.to_string().as_str()).to_contain("local_pool.rs") | ||
// // expect(err.to_string().as_str()).to_contain("catch_unwind.rs") | ||
// } | ||
|
||
// sweet! { | ||
|
||
// test "file context" { | ||
// let ctx = file_context(); | ||
// expect(ctx.as_str()).to_contain("let ctx = backtracer::file_context();")?; | ||
// // expect(false).to_be_true()?; | ||
// } | ||
|
||
// test "level 1: declarative"{ | ||
// let result = expect(true).to_be(false); | ||
// declarative_level(result.unwrap_err())?; | ||
// } | ||
|
||
// test "level 2: assertion"{ | ||
// let result = expect(true).assert_equal(false); | ||
// assertion_level(result.unwrap_err())?; | ||
// let result = expect(true).assert_correct(false,&false); | ||
// assertion_level(result.unwrap_err())?; | ||
// let result = expect(true).assert_correct_with_received(false,&false,&true); | ||
// assertion_level(result.unwrap_err())?; | ||
// } | ||
|
||
// test "level 3: error"{ | ||
// let err = expect(true).to_error(&false); | ||
// error_level(err)?; | ||
// let err = expect(true).to_error_with_received(&false,&true); | ||
// error_level(err)?; | ||
// let err = expect(true).to_error_with_backtrace(&false,0); | ||
// error_level(err)?; | ||
|
||
// // dont think this one is effective | ||
// // let err = expect(true).to_error_with_received_and_backtrace(&false,&true,0); | ||
// // assertion_level(err)?; | ||
// } | ||
// } |
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 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 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 |
---|---|---|
|
@@ -12,7 +12,6 @@ | |
``` | ||
1. create file `test/sweet.rs` | ||
```rs | ||
#![feature(imported_main)] | ||
pub use sweet::*; | ||
|
||
#[sweet_test] | ||
|
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