aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jorge Aparicio <jorge@japaric.io> 2018-09-06 01:04:39 +0200
committerGravatar Jorge Aparicio <jorge@japaric.io> 2018-09-06 01:04:39 +0200
commitbc526b8d74cb548c9da8d5c10d6013008e164ba5 (patch)
treeff1097f2fd427ae20c3ddb4a53db9d29c5bc649c
parent306c3fbb7e9f186a43c0a82c43b6a1f16b88df98 (diff)
downloadcortex-m-bc526b8d74cb548c9da8d5c10d6013008e164ba5.tar.gz
cortex-m-bc526b8d74cb548c9da8d5c10d6013008e164ba5.tar.zst
cortex-m-bc526b8d74cb548c9da8d5c10d6013008e164ba5.zip
add compile-fail tests for passing arguments to the attributes
-rw-r--r--cortex-m-rt/macros/src/lib.rs15
-rw-r--r--cortex-m-rt/tests/compile-fail/entry-args.rs13
-rw-r--r--cortex-m-rt/tests/compile-fail/exception-args.rs16
-rw-r--r--cortex-m-rt/tests/compile-fail/pre-init-args.rs16
4 files changed, 51 insertions, 9 deletions
diff --git a/cortex-m-rt/macros/src/lib.rs b/cortex-m-rt/macros/src/lib.rs
index e37eb9c..da21954 100644
--- a/cortex-m-rt/macros/src/lib.rs
+++ b/cortex-m-rt/macros/src/lib.rs
@@ -92,9 +92,8 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream {
"`#[entry]` function must have signature `fn() -> !`"
);
- assert_eq!(
- args.to_string(),
- "",
+ assert!(
+ args.to_string() == "",
"`entry` attribute must have no arguments"
);
@@ -250,9 +249,8 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream {
pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream {
let f: ItemFn = syn::parse(input).expect("`#[exception]` must be applied to a function");
- assert_eq!(
- args.to_string(),
- "",
+ assert!(
+ args.to_string() == "",
"`exception` attribute must have no arguments"
);
@@ -473,9 +471,8 @@ pub fn pre_init(args: TokenStream, input: TokenStream) -> TokenStream {
"`#[pre_init]` function must have signature `unsafe fn()`"
);
- assert_eq!(
- args.to_string(),
- "",
+ assert!(
+ args.to_string() == "",
"`pre_init` attribute must have no arguments"
);
diff --git a/cortex-m-rt/tests/compile-fail/entry-args.rs b/cortex-m-rt/tests/compile-fail/entry-args.rs
new file mode 100644
index 0000000..07cb4bd
--- /dev/null
+++ b/cortex-m-rt/tests/compile-fail/entry-args.rs
@@ -0,0 +1,13 @@
+#![no_main]
+#![no_std]
+
+extern crate cortex_m_rt;
+extern crate panic_semihosting;
+
+use cortex_m_rt::entry;
+
+#[entry(foo)] //~ ERROR custom attribute panicked
+//~^ HELP `entry` attribute must have no arguments
+fn foo() -> ! {
+ loop {}
+}
diff --git a/cortex-m-rt/tests/compile-fail/exception-args.rs b/cortex-m-rt/tests/compile-fail/exception-args.rs
new file mode 100644
index 0000000..85613ff
--- /dev/null
+++ b/cortex-m-rt/tests/compile-fail/exception-args.rs
@@ -0,0 +1,16 @@
+#![no_main]
+#![no_std]
+
+extern crate cortex_m_rt;
+extern crate panic_semihosting;
+
+use cortex_m_rt::{entry, exception};
+
+#[entry]
+fn foo() -> ! {
+ loop {}
+}
+
+#[exception(SysTick)] //~ ERROR custom attribute panicked
+//~^ HELP `exception` attribute must have no arguments
+fn SysTick() {}
diff --git a/cortex-m-rt/tests/compile-fail/pre-init-args.rs b/cortex-m-rt/tests/compile-fail/pre-init-args.rs
new file mode 100644
index 0000000..716b211
--- /dev/null
+++ b/cortex-m-rt/tests/compile-fail/pre-init-args.rs
@@ -0,0 +1,16 @@
+#![no_main]
+#![no_std]
+
+extern crate cortex_m_rt;
+extern crate panic_semihosting;
+
+use cortex_m_rt::{entry, pre_init};
+
+#[pre_init(foo)] //~ ERROR custom attribute panicked
+//~^ HELP `pre_init` attribute must have no arguments
+unsafe fn foo() {}
+
+#[entry]
+fn baz() -> ! {
+ loop {}
+}
rray.test.ts?h=feat/npm&id=ed421855d70c64f55a5cb15a1a46798457697d3e'>treecommitdiff
path: root/test/bun.js/node-stream-uint8array.test.ts (unfollow)
AgeCommit message (Expand)AuthorFilesLines
2023-01-21Handle string subclasses and new String() in new BufferGravatar Jarred Sumner 1-2/+11
2023-01-21Make Buffer.alloc* 3ns fasterGravatar Jarred Sumner 1-11/+17
2023-01-21[buffer] Make Buffer.from pass more testsGravatar Jarred Sumner 4-92/+179
2023-01-20constructor parameter properties in class expressions (#1867)Gravatar Dylan Conway 2-8/+48
2023-01-20Update transpiler.test.jsbun-v0.5.1Gravatar Jarred Sumner 1-1/+1
2023-01-20Update transpiler.test.jsGravatar Jarred Sumner 1-1/+1
2023-01-20push super before generated statements (#1856)Gravatar Dylan Conway 2-29/+53
2023-01-20Clear the errorsGravatar Jarred Sumner 1-0/+2
2023-01-20one less hash tableGravatar Jarred Sumner 1-2/+13
2023-01-20Add another testGravatar Jarred Sumner 2-1/+11
2023-01-20fix hanging testGravatar Jarred Sumner 1-38/+42
2023-01-20Further cleanup buffer encodingGravatar Jarred Sumner 1-48/+26
2023-01-20Fixes #1855Gravatar Jarred Sumner 2-5/+57
2023-01-20Fix assertion failure with boringssl messagesGravatar Jarred Sumner 3-5/+132
2023-01-19Revert "ignore sighup"Gravatar Jarred Sumner 1-45/+10
2023-01-19ignore sighupGravatar Jarred Sumner 1-10/+45
2023-01-19make this code easier to readGravatar Jarred Sumner 3-29/+26
2023-01-19Update types.zigGravatar Jarred Sumner 1-4/+0
2023-01-19BumpGravatar Jarred Sumner 2-2/+2
2023-01-19Fix buffer encoding bugGravatar Jarred Sumner 2-4/+17
2023-01-19use `String.from()` (#1850)Gravatar Alex Lam S.L 4-5/+12
2023-01-19Bump zigGravatar Jarred Sumner 2-2/+2
2023-01-19make it packedGravatar Jarred Sumner 1-2/+2
2023-01-20Bugfixes to install (#1848)Gravatar Jarred Sumner 5-26/+119
2023-01-19repopulate `alias_map` correctly (#1847)Gravatar Alex Lam S.L 5-70/+240
2023-01-19Add a commentGravatar Jarred Sumner 1-0/+6
2023-01-19Add a debug safety check for UAF in AST nodesGravatar Jarred Sumner 1-0/+5
2023-01-19Fix UAF when opening workspacesGravatar Jarred Sumner 1-2/+0
2023-01-19Improve error message when a workspace is not foundGravatar Jarred Sumner 2-9/+97