Repository: Geal/nom
Pull request #1349 (2021-08-04 15:28:24)

Remove more macros from tests
I went through all issue tests and removed all macro related issue tests.

`tests/` is now done and green.

related: #1343 


Patch:
diff --git a/Cargo.toml b/Cargo.toml
index 9764321..1b1bbff 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -81,9 +81,6 @@ name = "custom_errors"
 [[test]]
 name = "float"
 
-[[test]]
-name = "inference"
-
 [[test]]
 name = "ini"
 required-features = ["alloc"]
@@ -107,9 +104,6 @@ required-features = ["alloc"]
 name = "multiline"
 required-features = ["alloc"]
 
-[[test]]
-name = "named_args"
-
 [[test]]
 name = "overflow"
 
@@ -140,11 +134,6 @@ name = "ini"
 path = "benches/ini.rs"
 harness = false
 
-[[bench]]
-name = "ini_complete"
-path = "benches/ini_complete.rs"
-harness = false
-
 [[bench]]
 name = "ini_str"
 path = "benches/ini_str.rs"
diff --git a/benches/ini.rs b/benches/ini.rs
index f022e25..160eee9 100644
--- a/benches/ini.rs
+++ b/benches/ini.rs
@@ -1,5 +1,3 @@
-#[macro_use]
-extern crate nom;
 extern crate criterion;
 extern crate jemallocator;
 
@@ -13,8 +11,9 @@ use nom::{
   character::complete::{
     alphanumeric1 as alphanumeric, char, multispace1 as multispace, space1 as space,
   },
-  combinator::map_res,
-  sequence::delimited,
+  combinator::{map, map_res, opt},
+  multi::many0,
+  sequence::{delimited, pair, separated_pair, terminated, tuple},
   IResult,
 };
 use std::collections::HashMap;
@@ -27,208 +26,27 @@ fn category(i: &[u8]) -> IResult<&[u8], &str> {
   )(i)
 }
 
-named!(key_value    <&[u8],(&str,&str)>,
-  do_parse!(
-     key: map_res!(alphanumeric, str::from_utf8)
-  >>      opt!(space)
-  >>      char!('=')
-  >>      opt!(space)
-  >> val: map_res!(
-           take_while!(call!(|c| c != '\n' as u8 && c != ';' as u8)),
-           str::from_utf8
-         )
-  >>      opt!(pair!(char!(';'), take_while!(call!(|c| c != '\n' as u8))))
-  >>      (key, val)
-  )
-);
-
-named!(keys_and_values<&[u8], HashMap<&str, &str> >,
-  map!(
-    many0!(terminated!(key_value, opt!(multispace))),
-    |vec: Vec<_>| vec.into_iter().collect()
-  )
-);
-
-named!(category_and_keys<&[u8],(&str,HashMap<&str,&str>)>,
-  do_parse!(
-    category: category         >>
-              opt!(multispace) >>
-    keys: keys_and_values      >>
-    (category, keys)
-  )
-);
-
-named!(categories<&[u8], HashMap<&str, HashMap<&str,&str> > >,
-  map!(
-    many0!(
-      separated_pair!(
-        category,
-        opt!(multispace),
-        map!(
-          many0!(terminated!(key_value, opt!(multispace))),
-          |vec: Vec<_>| vec.into_iter().collect()
-        )
-      )
-    ),
-    |vec: Vec<_>| vec.into_iter().collect()
-  )
-);
-
-/*
-#[test]
-fn parse_category_test() {
-  let ini_file = &b"[category]
-
-parameter=value
-key = value2"[..];
-
-  let ini_without_category = &b"parameter=value
-key = value2"[..];
-
-  let res = category(ini_file);
-  println!("{:?}", res);
-  match res {
-    IResult::Done(i, o) => println!("i: {:?} | o: {:?}", str::from_utf8(i), o),
-    _ => println!("error")
-  }
-
-  assert_eq!(res, IResult::Done(ini_without_category, "category"));
+fn key_value(i: &[u8]) -> IResult<&[u8], (&str, &str)> {
+  let (i, key) = map_res(alphanumeric, str::from_utf8)(i)?;
+  let (i, _) = tuple((opt(space), char('='), opt(space)))(i)?;
+  let (i, val) = map_res(take_while(|c| c != b'\n' && c != b';'), str::from_utf8)(i)?;
+  let (i, _) = opt(pair(char(';'), take_while(|c| c != b'\n')))(i)?;
+  Ok((i, (key, val)))
 }
 
-#[test]
-fn parse_key_value_test() {
-  let ini_file = &b"parameter=value
-key = value2"[..];
-
-  let ini_without_key_value = &b"key = value2"[..];
-
-  let res = key_value(ini_file);
-  println!("{:?}", res);
-  match res {
-    IResult::Done(i, (o1, o2)) => println!("i: {:?} | o: ({:?},{:?})", str::from_utf8(i), o1, o2),
-    _ => println!("error")
-  }
-
-  assert_eq!(res, IResult::Done(ini_without_key_value, ("parameter", "value")));
-}
-
-
-#[test]
-fn parse_key_value_with_space_test() {
-  let ini_file = &b"parameter = value
-key = value2"[..];
-
-  let ini_without_key_value = &b"key = value2"[..];
-
-  let res = key_value(ini_file);
-  println!("{:?}", res);
-  match res {
-    IResult::Done(i, (o1, o2)) => println!("i: {:?} | o: ({:?},{:?})", str::from_utf8(i), o1, o2),
-    _ => println!("error")
-  }
-
-  assert_eq!(res, IResult::Done(ini_without_key_value, ("parameter", "value")));
-}
-
-#[test]
-fn parse_key_value_with_comment_test() {
-  let ini_file = &b"parameter=value;abc
-key = value2"[..];
-
-  let ini_without_key_value = &b"key = value2"[..];
-
-  let res = key_value(ini_file);
-  println!("{:?}", res);
-  match res {
-    IResult::Done(i, (o1, o2)) => println!("i: {:?} | o: ({:?},{:?})", str::from_utf8(i), o1, o2),
-    _ => println!("error")
-  }
-
-  assert_eq!(res, IResult::Done(ini_without_key_value, ("parameter", "value")));
-}
-
-#[test]
-fn parse_multiple_keys_and_values_test() {
-  let ini_file = &b"parameter=value;abc
-
-key = value2
-
-[category]"[..];
-
-  let ini_without_key_value = &b"[category]"[..];
-
-  let res = keys_and_values(ini_file);
-  println!("{:?}", res);
-  match res {
-    IResult::Done(i, ref o) => println!("i: {:?} | o: {:?}", str::from_utf8(i), o),
-    _ => println!("error")
-  }
-
-  let mut expected: HashMap<&str, &str> = HashMap::new();
-  expected.insert("parameter", "value");
-  expected.insert("key", "value2");
-  assert_eq!(res, IResult::Done(ini_without_key_value, expected));
-}
-
-#[test]
-fn parse_category_then_multiple_keys_and_values_test() {
-  //FIXME: there can be an empty line or a comment line after a category
-  let ini_file = &b"[abcd]
-parameter=value;abc
-
-key = value2
-
-[category]"[..];
-
-  let ini_after_parser = &b"[category]"[..];
-
-  let res = category_and_keys(ini_file);
-  println!("{:?}", res);
-  match res {
-    IResult::Done(i, ref o) => println!("i: {:?} | o: {:?}", str::from_utf8(i), o),
-    _ => println!("error")
-  }
-
-  let mut expected_h: HashMap<&str, &str> = HashMap::new();
-  expected_h.insert("parameter", "value");
-  expected_h.insert("key", "value2");
-  assert_eq!(res, IResult::Done(ini_after_parser, ("abcd", expected_h)));
-}
-
-#[test]
-fn parse_multiple_categories_test() {
-  let ini_file = &b"[abcd]
-
-parameter=value;abc
-
-key = value2
-
-[category]
-parameter3=value3
-key4 = value4
-\0"[..];
-
-  let ini_after_parser = &b"\0"[..];
-
-  let res = categories(ini_file);
-  //println!("{:?}", res);
-  match res {
-    IResult::Done(i, ref o) => println!("i: {:?} | o: {:?}", str::from_utf8(i), o),
-    _ => println!("error")
-  }
-
-  let mut expected_1: HashMap<&str, &str> = HashMap::new();
-  expected_1.insert("parameter", "value");
-  expected_1.insert("key", "value2");
-  let mut expected_2: HashMap<&str, &str> = HashMap::new();
-  expected_2.insert("parameter3", "value3");
-  expected_2.insert("key4", "value4");
-  let mut expected_h: HashMap<&str, HashMap<&str, &str>> = HashMap::new();
-  expected_h.insert("abcd",     expected_1);
-  expected_h.insert("category", expected_2);
-  assert_eq!(res, IResult::Done(ini_after_parser, expected_h));
+fn categories(i: &[u8]) -> IResult<&[u8], HashMap<&str, HashMap<&str, &str>>> {
+  map(
+    many0(separated_pair(
+      category,
+      opt(multispace),
+      map(
+        many0(terminated(key_value, opt(multispace))),
+        |vec: Vec<_>| vec.into_iter().collect(),
+      ),
+    )),
+    |vec: Vec<_>| vec.into_iter().collect(),
+  )(i)
 }
-*/
 
 fn bench_ini(c: &mut Criterion) {
   let str = "[owner]
@@ -241,13 +59,11 @@ port=143
 file=payroll.dat
 \0";
 
-  c.bench(
-    "bench ini",
-    Benchmark::new("parse", move |b| {
-      b.iter(|| categories(str.as_bytes()).unwrap());
-    })
-    .throughput(Throughput::Bytes(str.len() as u64)),
-  );
+  let mut group = c.benchmark_group("ini");
+  group.throughput(Throughput::Bytes(str.len() as u64));
+  group.bench_function(BenchmarkId::new("parse", str.len()), |b| {
+    b.iter(|| categories(str.as_bytes()).unwrap())
+  });
 }
 
 fn bench_ini_keys_and_values(c: &mut Criterion) {
@@ -256,27 +72,25 @@ port=143
 file=payroll.dat
 \0";
 
-  named!(acc<Vec<(&str, &str)>>, many0!(key_value));
+  fn acc(i: &[u8]) -> IResult<&[u8], Vec<(&str, &str)>> {
+    many0(key_value)(i)
+  }
 
-  c.bench(
-    "bench ini keys and values",
-    Benchmark::new("parse", move |b| {
-      b.iter(|| acc(str.as_bytes()).unwrap());
-    })
-    .throughput(Throughput::Bytes(str.len() as u64)),
-  );
+  let mut group = c.benchmark_group("ini keys and values");
+  group.throughput(Throughput::Bytes(str.len() as u64));
+  group.bench_function(BenchmarkId::new("parse", str.len()), |b| {
+    b.iter(|| acc(str.as_bytes()).unwrap())
+  });
 }
 
 fn bench_ini_key_value(c: &mut Criterion) {
   let str = "server=192.0.2.62\n";
 
-  c.bench(
-    "bench ini key value",
-    Benchmark::new("parse", move |b| {
-      b.iter(|| key_value(str.as_bytes()).unwrap());
-    })
-    .throughput(Throughput::Bytes(str.len() as u64)),
-  );
+  let mut group = c.benchmark_group("ini key value");
+  group.throughput(Throughput::Bytes(str.len() as u64));
+  group.bench_function(BenchmarkId::new("parse", str.len()), |b| {
+    b.iter(|| key_value(str.as_bytes()).unwrap())
+  });
 }
 
 criterion_group!(
diff --git a/benches/ini_complete.rs b/benches/ini_complete.rs
deleted file mode 100644
index a847ef4..0000000
--- a/benches/ini_complete.rs
+++ /dev/null
@@ -1,303 +0,0 @@
-#[macro_use]
-extern crate nom;
-extern crate criterion;
-extern crate jemallocator;
-
-#[global_allocator]
-static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
-
-use criterion::*;
-use nom::{
-  bytes::complete::take_while,
-  character::complete::{
-    alphanumeric1 as alphanumeric, char, multispace1 as multispace, space1 as space,
-  },
-  combinator::map_res,
-  sequence::delimited,
-  IResult,
-};
-use std::collections::HashMap;
-use std::str;
-
-/*
-named!(category<&[u8], &str>, map_res!(
-    delimited!(
-      char!('['),
-      take_while!(call!(|c| c != b']')),
-      char!(']')
-    ),
-    complete_byte_slice_to_str
-));
-
-fn complete_byte_slice_to_str<'a>(s: &'a [u8]) -> Result<&'a str, str::Utf8Error> {
-  str::from_utf8(s)
-}
-*/
-
-fn category(i: &[u8]) -> IResult<&[u8], &str> {
-  map_res(
-    delimited(char('['), take_while(|c| c != b']'), char(']')),
-    str::from_utf8,
-  )(i)
-}
-
-fn complete_byte_slice_to_str<'a>(s: &'a [u8]) -> Result<&'a str, str::Utf8Error> {
-  str::from_utf8(s)
-}
-
-named!(key_value    <&[u8],(&str,&str)>,
-  do_parse!(
-     key: map_res!(alphanumeric, complete_byte_slice_to_str)
-  >>      opt!(space)
-  >>      char!('=')
-  >>      opt!(space)
-  >> val: map_res!(
-           take_while!(call!(|c| c != b'\n' && c != b';')),
-           complete_byte_slice_to_str
-         )
-  >>      opt!(pair!(char!(';'), take_while!(call!(|c| c != b'\n'))))
-  >>      (key, val)
-  )
-);
-
-named!(keys_and_values<&[u8], HashMap<&str, &str> >,
-  map!(
-    many0!(terminated!(key_value, opt!(multispace))),
-    |vec: Vec<_>| vec.into_iter().collect()
-  )
-);
-
-named!(category_and_keys<&[u8],(&str,HashMap<&str,&str>)>,
-  do_parse!(
-    category: category         >>
-              opt!(multispace) >>
-    keys: keys_and_values      >>
-    (category, keys)
-  )
-);
-
-named!(categories<&[u8], HashMap<&str, HashMap<&str,&str> > >,
-  map!(
-    many0!(
-      separated_pair!(
-        category,
-        opt!(multispace),
-        map!(
-          many0!(terminated!(key_value, opt!(multispace))),
-          |vec: Vec<_>| vec.into_iter().collect()
-        )
-      )
-    ),
-    |vec: Vec<_>| vec.into_iter().collect()
-  )
-);
-
-#[test]
-fn parse_category_test() {
-  let ini_file = &b"[category]
-
-parameter=value
-key = value2"[..];
-
-  let ini_without_category = &b"\n\nparameter=value
-key = value2"[..];
-
-  let res = category(ini_file);
-  println!("{:?}", res);
-  match res {
-    Ok((i, o)) => println!("i: {:?} | o: {:?}", str::from_utf8(i), o),
-    _ => println!("error"),
-  }
-
-  assert_eq!(res, Ok((ini_without_category, "category")));
-}
-
-#[test]
-fn parse_key_value_test() {
-  let ini_file = &b"parameter=value
-key = value2"[..];
-
-  let ini_without_key_value = &b"\nkey = value2"[..];
-
-  let res = key_value(ini_file);
-  println!("{:?}", res);
-  match res {
-    Ok((i, (o1, o2))) => println!("i: {:?} | o: ({:?},{:?})", str::from_utf8(i), o1, o2),
-    _ => println!("error"),
-  }
-
-  assert_eq!(res, Ok((ini_without_key_value, ("parameter", "value"))));
-}
-
-#[test]
-fn parse_key_value_with_space_test() {
-  let ini_file = &b"parameter = value
-key = value2"[..];
-
-  let ini_without_key_value = &b"\nkey = value2"[..];
-
-  let res = key_value(ini_file);
-  println!("{:?}", res);
-  match res {
-    Ok((i, (o1, o2))) => println!("i: {:?} | o: ({:?},{:?})", str::from_utf8(i), o1, o2),
-    _ => println!("error"),
-  }
-
-  assert_eq!(res, Ok((ini_without_key_value, ("parameter", "value"))));
-}
-
-#[test]
-fn parse_key_value_with_comment_test() {
-  let ini_file = &b"parameter=value;abc
-key = value2"[..];
-
-  let ini_without_key_value = &b"\nkey = value2"[..];
-
-  let res = key_value(ini_file);
-  println!("{:?}", res);
-  match res {
-    Ok((i, (o1, o2))) => println!("i: {:?} | o: ({:?},{:?})", str::from_utf8(i.0), o1, o2),
-    _ => println!("error"),
-  }
-
-  assert_eq!(res, Ok((ini_without_key_value, ("parameter", "value"))));
-}
-
-#[test]
-fn parse_multiple_keys_and_values_test() {
-  let ini_file = &b"parameter=value;abc
-
-key = value2
-
-[category]"[..];
-
-  let ini_without_key_value = &b"[category]"[..];
-
-  let res = keys_and_values(ini_file);
-  println!("{:?}", res);
-  match res {
-    Ok((i, ref o)) => println!("i: {:?} | o: {:?}", str::from_utf8(i), o),
-    _ => println!("error"),
-  }
-
-  let mut expected: HashMap<&str, &str> = HashMap::new();
-  expected.insert("parameter", "value");
-  expected.insert("key", "value2");
-  assert_eq!(res, Ok((ini_without_key_value, expected)));
-}
-
-#[test]
-fn parse_category_then_multiple_keys_and_values_test() {
-  //FIXME: there can be an empty line or a comment line after a category
-  let ini_file = &b"[abcd]
-parameter=value;abc
-
-key = value2
-
-[category]"[..];
-
-  let ini_after_parser = &b"[category]"[..];
-
-  let res = category_and_keys(ini_file);
-  println!("{:?}", res);
-  match res {
-    Ok((i, ref o)) => println!("i: {:?} | o: {:?}", str::from_utf8(i), o),
-    _ => println!("error"),
-  }
-
-  let mut expected_h: HashMap<&str, &str> = HashMap::new();
-  expected_h.insert("parameter", "value");
-  expected_h.insert("key", "value2");
-  assert_eq!(res, Ok((ini_after_parser, ("abcd", expected_h))));
-}
-
-#[test]
-fn parse_multiple_categories_test() {
-  let ini_file = &b"[abcd]
-
-parameter=value;abc
-
-key = value2
-
-[category]
-parameter3=value3
-key4 = value4
-"[..];
-
-  let ini_after_parser = &b""[..];
-
-  let res = categories(ini_file);
-  //println!("{:?}", res);
-  match res {
-    Ok((i, ref o)) => println!("i: {:?} | o: {:?}", str::from_utf8(i), o),
-    _ => println!("error"),
-  }
-
-  let mut expected_1: HashMap<&str, &str> = HashMap::new();
-  expected_1.insert("parameter", "value");
-  expected_1.insert("key", "value2");
-  let mut expected_2: HashMap<&str, &str> = HashMap::new();
-  expected_2.insert("parameter3", "value3");
-  expected_2.insert("key4", "value4");
-  let mut expected_h: HashMap<&str, HashMap<&str, &str>> = HashMap::new();
-  expected_h.insert("abcd", expected_1);
-  expected_h.insert("category", expected_2);
-  assert_eq!(res, Ok((ini_after_parser, expected_h)));
-}
-
-fn bench_ini_complete(c: &mut Criterion) {
-  let s = "[owner]
-name=John Doe
-organization=Acme Widgets Inc.
-
-[database]
-server=192.0.2.62
-port=143
-file=payroll.dat
-";
-
-  c.bench(
-    "bench ini complete",
-    Benchmark::new("parse", move |b| {
-      b.iter(|| categories(s.as_bytes()).unwrap());
-    })
-    .throughput(Throughput::Bytes(s.len() as u64)),
-  );
-}
-
-fn bench_ini_complete_keys_and_values(c: &mut Criterion) {
-  let s = "server=192.0.2.62
-port=143
-file=payroll.dat
-";
-
-  named!(acc<&[u8], Vec<(&str,&str)> >, many0!(key_value));
-
-  c.bench(
-    "bench ini complete keys and values",
-    Benchmark::new("parse", move |b| {
-      b.iter(|| acc(s.as_bytes()).unwrap());
-    })
-    .throughput(Throughput::Bytes(s.len() as u64)),
-  );
-}
-
-fn bench_ini_complete_key_value(c: &mut Criterion) {
-  let s = "server=192.0.2.62\n";
-
-  c.bench(
-    "bench ini complete key value",
-    Benchmark::new("parse", move |b| {
-      b.iter(|| key_value(s.as_bytes()).unwrap());
-    })
-    .throughput(Throughput::Bytes(s.len() as u64)),
-  );
-}
-
-criterion_group!(
-  benches,
-  bench_ini_complete,
-  bench_ini_complete_keys_and_values,
-  bench_ini_complete_key_value
-);
-criterion_main!(benches);
diff --git a/benches/ini_str.rs b/benches/ini_str.rs
index 456dc55..044f679 100644
--- a/benches/ini_str.rs
+++ b/benches/ini_str.rs
@@ -1,18 +1,17 @@
-#[macro_use]
-extern crate nom;
 extern crate criterion;
 extern crate jemallocator;
 
-use criterion::*;
-
 #[global_allocator]
 static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
 
+use criterion::*;
+
 use nom::{
-  bytes::complete::{is_a, take_while},
+  bytes::complete::{is_a, tag, take_till, take_while},
   character::complete::{alphanumeric1 as alphanumeric, char, not_line_ending, space0 as space},
   combinator::opt,
-  sequence::{delimited, terminated},
+  multi::many0,
+  sequence::{delimited, pair, terminated, tuple},
   IResult,
 };
 
@@ -33,21 +32,19 @@ fn category(i: &str) -> IResult<&str, &str> {
   )(i)
 }
 
-named!(key_value    <&str,(&str,&str)>,
-  do_parse!(
-    key: alphanumeric                              >>
-         opt!(space)                               >>
-         tag!("=")                               >>
-         opt!(space)                               >>
-    val: take_till!(is_line_ending_or_comment)   >>
-         opt!(space)                               >>
-         opt!(pair!(tag!(";"), not_line_ending)) >>
-         opt!(space_or_line_ending)                >>
-    (key, val)
-  )
-);
-
-named!(keys_and_values_aggregator<&str, Vec<(&str, &str)> >, many0!(key_value));
+fn key_value(i: &str) -> IResult<&str, (&str, &str)> {
+  let (i, key) = alphanumeric(i)?;
+  let (i, _) = tuple((opt(space), tag("="), opt(space)))(i)?;
+  let (i, val) = take_till(is_line_ending_or_comment)(i)?;
+  let (i, _) = opt(space)(i)?;
+  let (i, _) = opt(pair(tag(";"), not_line_ending))(i)?;
+  let (i, _) = opt(space_or_line_ending)(i)?;
+  Ok((i, (key, val)))
+}
+
+fn keys_and_values_aggregator(i: &str) -> IResult<&str, Vec<(&str, &str)>> {
+  many0(key_value)(i)
+}
 
 fn keys_and_values(input: &str) -> IResult<&str, HashMap<&str, &str>> {
   match keys_and_values_aggregator(input) {
@@ -56,11 +53,13 @@ fn keys_and_values(input: &str) -> IResult<&str, HashMap<&str, &str>> {
   }
 }
 
-named!(category_and_keys<&str,(&str,HashMap<&str,&str>)>,
-  pair!(category, keys_and_values)
-);
+fn category_and_keys(i: &str) -> IResult<&str, (&str, HashMap<&str, &str>)> {
+  pair(category, keys_and_values)(i)
+}
 
-named!(categories_aggregator<&str, Vec<(&str, HashMap<&str,&str>)> >, many0!(category_and_keys));
+fn categories_aggregator(i: &str) -> IResult<&str, Vec<(&str, HashMap<&str, &str>)>> {
+  many0(category_and_keys)(i)
+}
 
 fn categories(input: &str) -> IResult<&str, HashMap<&str, HashMap<&str, &str>>> {
   match categories_aggregator(input) {
@@ -69,157 +68,6 @@ fn categories(input: &str) -> IResult<&str, HashMap<&str, HashMap<&str, &str>>>
   }
 }
 
-#[test]
-fn parse_category_test() {
-  let ini_file = "[category]
-
-parameter=value
-key = value2";
-
-  let ini_without_category = "parameter=value
-key = value2";
-
-  let res = category(ini_file);
-  println!("{:?}", res);
-  match res {
-    Ok((i, o)) => println!("i: {} | o: {:?}", i.0, o),
-    _ => println!("error"),
-  }
-
-  assert_eq!(res, Ok((ini_without_category, "category")));
-}
-
-#[test]
-fn parse_key_value_test() {
-  let ini_file = "parameter=value
-key = value2";
-
-  let ini_without_key_value = "key = value2";
-
-  let res = key_value(ini_file);
-  println!("{:?}", res);
-  match res {
-    Ok((i, (o1, o2))) => println!("i: {} | o: ({:?},{:?})", i.0, o1, o2),
-    _ => println!("error"),
-  }
-
-  assert_eq!(res, Ok((ini_without_key_value, ("parameter", "value"))));
-}
-
-#[test]
-fn parse_key_value_with_space_test() {
-  let ini_file = "parameter = value
-key = value2";
-
-  let ini_without_key_value = "key = value2";
-
-  let res = key_value(ini_file);
-  println!("{:?}", res);
-  match res {
-    Ok((i, (o1, o2))) => println!("i: {} | o: ({:?},{:?})", i.0, o1, o2),
-    _ => println!("error"),
-  }
-
-  assert_eq!(res, Ok((ini_without_key_value, ("parameter", "value"))));
-}
-
-#[test]
-fn parse_key_value_with_comment_test() {
-  let ini_file = "parameter=value;abc
-key = value2";
-
-  let ini_without_key_value = "key = value2";
-
-  let res = key_value(ini_file);
-  println!("{:?}", res);
-  match res {
-    Ok((i, (o1, o2))) => println!("i: {} | o: ({:?},{:?})", i.0, o1, o2),
-    _ => println!("error"),
-  }
-
-  assert_eq!(res, Ok((ini_without_key_value, ("parameter", "value"))));
-}
-
-#[test]
-fn parse_multiple_keys_and_values_test() {
-  let ini_file = "parameter=value;abc
-
-key = value2
-
-[category]";
-
-  let ini_without_key_value = "[category]";
-
-  let res = keys_and_values(ini_file);
-  println!("{:?}", res);
-  match res {
-    Ok((i, ref o)) => println!("i: {} | o: {:?}", i.0, o),
-    _ => println!("error"),
-  }
-
-  let mut expected: HashMap<&str, &str> = HashMap::new();
-  expected.insert("parameter", "value");
-  expected.insert("key", "value2");
-  assert_eq!(res, Ok((ini_without_key_value, expected)));
-}
-
-#[test]
-fn parse_category_then_multiple_keys_and_values_test() {
-  //FIXME: there can be an empty line or a comment line after a category
-  let ini_file = "[abcd]
-parameter=value;abc
-
-key = value2
-
-[category]";
-
-  let ini_after_parser = "[category]";
-
-  let res = category_and_keys(ini_file);
-  println!("{:?}", res);
-  match res {
-    Ok((i, ref o)) => println!("i: {} | o: {:?}", i.0, o),
-    _ => println!("error"),
-  }
-
-  let mut expected_h: HashMap<&str, &str> = HashMap::new();
-  expected_h.insert("parameter", "value");
-  expected_h.insert("key", "value2");
-  assert_eq!(res, Ok((ini_after_parser, ("abcd", expected_h))));
-}
-
-#[test]
-fn parse_multiple_categories_test() {
-  let ini_file = "[abcd]
-
-parameter=value;abc
-
-key = value2
-
-[category]
-parameter3=value3
-key4 = value4
-";
-
-  let res = categories(ini_file);
-  //println!("{:?}", res);
-  match res {
-    Ok((i, ref o)) => println!("i: {} | o: {:?}", i.0, o),
-    _ => println!("error"),
-  }
-
-  let mut expected_1: HashMap<&str, &str> = HashMap::new();
-  expected_1.insert("parameter", "value");
-  expected_1.insert("key", "value2");
-  let mut expected_2: HashMap<&str, &str> = HashMap::new();
-  expected_2.insert("parameter3", "value3");
-  expected_2.insert("key4", "value4");
-  let mut expected_h: HashMap<&str, HashMap<&str, &str>> = HashMap::new();
-  expected_h.insert("abcd", expected_1);
-  expected_h.insert("category", expected_2);
-  assert_eq!(res, Ok(("", expected_h)));
-}
-
 fn bench_ini_str(c: &mut Criterion) {
   let s = "[owner]
 name=John Doe
@@ -231,13 +79,11 @@ port=143
 file=payroll.dat
 ";
 
-  c.bench(
-    "bench ini str",
-    Benchmark::new("parse", move |b| {
-      b.iter(|| categories(s).unwrap());
-    })
-    .throughput(Throughput::Bytes(s.len() as u64)),
-  );
+  let mut group = c.benchmark_group("ini str");
+  group.throughput(Throughput::Bytes(s.len() as u64));
+  group.bench_function(BenchmarkId::new("parse", s.len()), |b| {
+    b.iter(|| categories(s).unwrap())
+  });
 }
 
 criterion_group!(benches, bench_ini_str);
diff --git a/src/bytes/macros.rs b/src/bytes/macros.rs
index 17719f9..1c1ffc0 100644
--- a/src/bytes/macros.rs
+++ b/src/bytes/macros.rs
@@ -133,30 +133,6 @@ macro_rules! escaped (
 /// * The third argument matches the escaped characters and transforms them
 ///
 /// As an example, the chain `abc\tdef` could be `abc    def` (it also consumes the control character).
-/// # Example
-/// ```rust
-/// # #[macro_use] extern crate nom;
-/// # use nom::character::complete::alpha1;
-/// # use nom::lib::std::str::from_utf8;
-/// # fn main() {
-/// fn to_s(i:Vec<u8>) -> String {
-///   String::from_utf8_lossy(&i).into_owned()
-/// }
-///
-///  named!(transform < String >,
-///    map!(
-///      escaped_transform!(call!(alpha1), '\\',
-///        alt!(
-///            tag!("\\")       => { |_| &b"\\"[..] }
-///          | tag!("\"")       => { |_| &b"\""[..] }
-///          | tag!("n")        => { |_| &b"\n"[..] }
-///        )
-///      ), to_s
-///    )
-///  );
-///  assert_eq!(transform(&b"ab\\\"cd"[..]), Ok((&b""[..], String::from("ab\"cd"))));
-/// # }
-/// ```
 #[cfg(feature = "alloc")]
 #[cfg_attr(feature = "docsrs", doc(cfg(feature = "alloc")))]
 #[macro_export(local_inner_macros)]
@@ -436,15 +412,20 @@ macro_rules! take_until1 (
 
 #[cfg(test)]
 mod tests {
+  #[cfg(feature = "alloc")]
+  use crate::bytes::complete::escaped_transform;
+  #[cfg(feature = "alloc")]
+  use crate::bytes::complete::tag;
   use crate::character::is_alphabetic;
   use crate::character::streaming::{
     alpha1 as alpha, alphanumeric1 as alphanumeric, digit1 as digit, hex_digit1 as hex_digit,
     multispace1 as multispace, oct_digit1 as oct_digit, space1 as space,
   };
-  use crate::bytes::complete::{escaped_transform, tag};
   use crate::error::ErrorKind;
   use crate::internal::{Err, IResult, Needed};
+  #[cfg(feature = "alloc")]
   use crate::branch::alt;
+  #[cfg(feature = "alloc")]
   use crate::combinator::{map, value};
   #[cfg(feature = "alloc")]
   use crate::lib::std::string::String;
diff --git a/src/combinator/macros.rs b/src/combinator/macros.rs
index 11ece16..b66d519 100644
--- a/src/combinator/macros.rs
+++ b/src/combinator/macros.rs
@@ -131,67 +131,6 @@ macro_rules! named (
     );
 );
 
-/// Makes a function from a parser combination with arguments.
-///
-/// ```ignore
-/// //takes [`&[u8]`] as input
-/// named_args!(tagged(open_tag: &[u8], close_tag: &[u8])<&str>,
-///   delimited!(tag!(open_tag), map_res!(take!(4), str::from_utf8), tag!(close_tag))
-/// );
-
-/// //takes `&str` as input
-/// named_args!(tagged(open_tag: &str, close_tag: &str)<&str, &str>,
-///   delimited!(tag!(open_tag), take!(4), tag!(close_tag))
-/// );
-/// ```
-///
-/// Note: If using arguments that way gets hard to read, it is always
-/// possible to write the equivalent parser definition manually, like
-/// this:
-///
-/// ```ignore
-/// fn tagged(input: &[u8], open_tag: &[u8], close_tag: &[u8]) -> IResult<&[u8], &str> {
-///   // the first combinator in the tree gets the input as argument. It is then
-///   // passed from one combinator to the next through macro rewriting
-///   delimited!(input,
-///     tag!(open_tag), take!(4), tag!(close_tag)
-///   )
-/// );
-/// ```
-///
-#[macro_export(local_inner_macros)]
-macro_rules! named_args {
-    ($vis:vis $func_name:ident ( $( $arg:ident : $typ:ty ),* ) < $return_type:ty > , $submac:ident!( $($args:tt)* ) ) => {
-        $vis fn $func_name(input: &[u8], $( $arg : $typ ),*) -> $crate::IResult<&[u8], $return_type> {
-            $submac!(input, $($args)*)
-        }
-    };
-
-    ($vis:vis $func_name:ident < 'a > ( $( $arg:ident : $typ:ty ),* ) < $return_type:ty > , $submac:ident!( $($args:tt)* ) ) => {
-        $vis fn $func_name<'this_is_probably_unique_i_hope_please, 'a>(
-          input: &'this_is_probably_unique_i_hope_please [u8], $( $arg : $typ ),*) ->
-          $crate::IResult<&'this_is_probably_unique_i_hope_please [u8], $return_type>
-        {
-          $submac!(input, $($args)*)
-        }
-    };
-
-    ($vis:vis $func_name:ident ( $( $arg:ident : $typ:ty ),* ) < $input_type:ty, $return_type:ty > , $submac:ident!( $($args:tt)* ) ) => {
-        $vis fn $func_name(input: $input_type, $( $arg : $typ ),*) -> $crate::IResult<$input_type, $return_type> {
-            $submac!(input, $($args)*)
-        }
-    };
-
-    ($vis:vis $func_name:ident < 'a > ( $( $arg:ident : $typ:ty ),* ) < $input_type:ty, $return_type:ty > , $submac:ident!( $($args:tt)* ) ) => {
-        $vis fn $func_name<'a>(
-          input: $input_type, $( $arg : $typ ),*)
-          -> $crate::IResult<$input_type, $return_type>
-        {
-            $submac!(input, $($args)*)
-        }
-    };
-}
-
 /// Makes a function from a parser combination, with attributes.
 ///
 /// The usage of this macro is almost identical to `named!`, except that
@@ -282,38 +221,6 @@ macro_rules! call (
 /// Additionally, the error chain contains number identifiers
 /// that can be matched to provide useful error messages.
 ///
-/// ```
-/// # #[macro_use] extern crate nom;
-/// # use nom::Err;
-/// # use nom::error::ErrorKind;
-/// # fn main() {
-///     named!(err_test<&[u8], &[u8]>, alt!(
-///       tag!("abcd") |
-///       preceded!(tag!("efgh"), return_error!(ErrorKind::Eof,
-///           do_parse!(
-///                  tag!("ijkl")                                        >>
-///             res: return_error!(ErrorKind::Tag, tag!("mnop")) >>
-///             (res)
-///           )
-///         )
-///       )
-///     ));
-///     let a = &b"efghblah"[..];
-///     let b = &b"efghijklblah"[..];
-///     let c = &b"efghijklmnop"[..];
-///
-///     let blah = &b"blah"[..];
-///
-///     let res_a = err_test(a);
-///     let res_b = err_test(b);
-///     let res_c = err_test(c);
-///     assert_eq!(res_a, Err(Err::Failure(error_node_position!(blah, ErrorKind::Eof, error_position!(blah, ErrorKind::Tag)))));
-///     assert_eq!(res_b, Err(Err::Failure(error_node_position!(&b"ijklblah"[..], ErrorKind::Eof,
-///       error_node_position!(blah, ErrorKind::Tag, error_position!(blah, ErrorKind::Tag))))
-///     ));
-/// # }
-/// ```
-///
 #[macro_export(local_inner_macros)]
 macro_rules! return_error (
   ($i:expr, $code:expr, $submac:ident!( $($args:tt)* )) => (
diff --git a/src/number/complete.rs b/src/number/complete.rs
index ffebf23..3e076db 100644
--- a/src/number/complete.rs
+++ b/src/number/complete.rs
@@ -1900,4 +1900,87 @@ mod tests {
       Err(Err::Failure(("", ErrorKind::Digit)))
     );
   }
+
+  #[test]
+  fn configurable_endianness() {
+    use crate::number::Endianness;
+
+    fn be_tst16(i: &[u8]) -> IResult<&[u8], u16> {
+      u16(Endianness::Big)(i)
+    }
+    fn le_tst16(i: &[u8]) -> IResult<&[u8], u16> {
+      u16(Endianness::Little)(i)
+    }
+    assert_eq!(be_tst16(&[0x80, 0x00]), Ok((&b""[..], 32_768_u16)));
+    assert_eq!(le_tst16(&[0x80, 0x00]), Ok((&b""[..], 128_u16)));
+
+    fn be_tst32(i: &[u8]) -> IResult<&[u8], u32> {
+      u32(Endianness::Big)(i)
+    }
+    fn le_tst32(i: &[u8]) -> IResult<&[u8], u32> {
+      u32(Endianness::Little)(i)
+    }
+    assert_eq!(
+      be_tst32(&[0x12, 0x00, 0x60, 0x00]),
+      Ok((&b""[..], 302_014_464_u32))
+    );
+    assert_eq!(
+      le_tst32(&[0x12, 0x00, 0x60, 0x00]),
+      Ok((&b""[..], 6_291_474_u32))
+    );
+
+    fn be_tst64(i: &[u8]) -> IResult<&[u8], u64> {
+      u64(Endianness::Big)(i)
+    }
+    fn le_tst64(i: &[u8]) -> IResult<&[u8], u64> {
+      u64(Endianness::Little)(i)
+    }
+    assert_eq!(
+      be_tst64(&[0x12, 0x00, 0x60, 0x00, 0x12, 0x00, 0x80, 0x00]),
+      Ok((&b""[..], 1_297_142_246_100_992_000_u64))
+    );
+    assert_eq!(
+      le_tst64(&[0x12, 0x00, 0x60, 0x00, 0x12, 0x00, 0x80, 0x00]),
+      Ok((&b""[..], 36_028_874_334_666_770_u64))
+    );
+
+    fn be_tsti16(i: &[u8]) -> IResult<&[u8], i16> {
+      i16(Endianness::Big)(i)
+    }
+    fn le_tsti16(i: &[u8]) -> IResult<&[u8], i16> {
+      i16(Endianness::Little)(i)
+    }
+    assert_eq!(be_tsti16(&[0x00, 0x80]), Ok((&b""[..], 128_i16)));
+    assert_eq!(le_tsti16(&[0x00, 0x80]), Ok((&b""[..], -32_768_i16)));
+
+    fn be_tsti32(i: &[u8]) -> IResult<&[u8], i32> {
+      i32(Endianness::Big)(i)
+    }
+    fn le_tsti32(i: &[u8]) -> IResult<&[u8], i32> {
+      i32(Endianness::Little)(i)
+    }
+    assert_eq!(
+      be_tsti32(&[0x00, 0x12, 0x60, 0x00]),
+      Ok((&b""[..], 1_204_224_i32))
+    );
+    assert_eq!(
+      le_tsti32(&[0x00, 0x12, 0x60, 0x00]),
+      Ok((&b""[..], 6_296_064_i32))
+    );
+
+    fn be_tsti64(i: &[u8]) -> IResult<&[u8], i64> {
+      i64(Endianness::Big)(i)
+    }
+    fn le_tsti64(i: &[u8]) -> IResult<&[u8], i64> {
+      i64(Endianness::Little)(i)
+    }
+    assert_eq!(
+      be_tsti64(&[0x00, 0xFF, 0x60, 0x00, 0x12, 0x00, 0x80, 0x00]),
+      Ok((&b""[..], 71_881_672_479_506_432_i64))
+    );
+    assert_eq!(
+      le_tsti64(&[0x00, 0xFF, 0x60, 0x00, 0x12, 0x00, 0x80, 0x00]),
+      Ok((&b""[..], 36_028_874_334_732_032_i64))
+    );
+  }
 }
diff --git a/src/number/macros.rs b/src/number/macros.rs
deleted file mode 100644
index 27fdcce..0000000
--- a/src/number/macros.rs
+++ /dev/null
@@ -1,265 +0,0 @@
-//! Parsers recognizing numbers
-
-/// If the parameter is `nom::number::Endianness::Big`, parse a big endian u16 integer,
-/// otherwise a little endian u16 integer.
-///
-/// ```rust
-/// # #[macro_use] extern crate nom;
-/// # use nom::{Err, Needed};
-/// use nom::number::Endianness;
-///
-/// # fn main() {
-/// named!(be<u16>, u16!(Endianness::Big));
-///
-/// assert_eq!(be(b"\x00\x01abcd"), Ok((&b"abcd"[..], 0x0001)));
-/// assert_eq!(be(b"\x01"), Err(Err::Incomplete(Needed::new(1))));
-///
-/// named!(le<u16>, u16!(Endianness::Little));
-///
-/// assert_eq!(le(b"\x00\x01abcd"), Ok((&b"abcd"[..], 0x0100)));
-/// assert_eq!(le(b"\x01"), Err(Err::Incomplete(Needed::new(1))));
-/// # }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! u16 ( ($i:expr, $e:expr) => ( {if $crate::number::Endianness::Big == $e { $crate::number::streaming::be_u16($i) } else { $crate::number::streaming::le_u16($i) } } ););
-
-/// If the parameter is `nom::number::Endianness::Big`, parse a big endian u32 integer,
-/// otherwise a little endian u32 integer.
-///
-/// ```rust
-/// # #[macro_use] extern crate nom;
-/// # use nom::{Err, Needed};
-/// use nom::number::Endianness;
-///
-/// # fn main() {
-/// named!(be<u32>, u32!(Endianness::Big));
-///
-/// assert_eq!(be(b"\x00\x01\x02\x03abcd"), Ok((&b"abcd"[..], 0x00010203)));
-/// assert_eq!(be(b"\x01"), Err(Err::Incomplete(Needed::new(3))));
-///
-/// named!(le<u32>, u32!(Endianness::Little));
-///
-/// assert_eq!(le(b"\x00\x01\x02\x03abcd"), Ok((&b"abcd"[..], 0x03020100)));
-/// assert_eq!(le(b"\x01"), Err(Err::Incomplete(Needed::new(3))));
-/// # }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! u32 ( ($i:expr, $e:expr) => ( {if $crate::number::Endianness::Big == $e { $crate::number::streaming::be_u32($i) } else { $crate::number::streaming::le_u32($i) } } ););
-
-/// If the parameter is `nom::number::Endianness::Big`, parse a big endian u64 integer,
-/// otherwise a little endian u64 integer.
-///
-/// ```rust
-/// # #[macro_use] extern crate nom;
-/// # use nom::{Err, Needed};
-/// use nom::number::Endianness;
-///
-/// # fn main() {
-/// named!(be<u64>, u64!(Endianness::Big));
-///
-/// assert_eq!(be(b"\x00\x01\x02\x03\x04\x05\x06\x07abcd"), Ok((&b"abcd"[..], 0x0001020304050607)));
-/// assert_eq!(be(b"\x01"), Err(Err::Incomplete(Needed::new(7))));
-///
-/// named!(le<u64>, u64!(Endianness::Little));
-///
-/// assert_eq!(le(b"\x00\x01\x02\x03\x04\x05\x06\x07abcd"), Ok((&b"abcd"[..], 0x0706050403020100)));
-/// assert_eq!(le(b"\x01"), Err(Err::Incomplete(Needed::new(7))));
-/// # }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! u64 ( ($i:expr, $e:expr) => ( {if $crate::number::Endianness::Big == $e { $crate::number::streaming::be_u64($i) } else { $crate::number::streaming::le_u64($i) } } ););
-
-/// If the parameter is `nom::number::Endianness::Big`, parse a big endian u128 integer,
-/// otherwise a little endian u128 integer.
-///
-/// ```rust
-/// # #[macro_use] extern crate nom;
-/// # use nom::{Err, Needed};
-/// use nom::number::Endianness;
-///
-/// # fn main() {
-/// named!(be<u128>, u128!(Endianness::Big));
-///
-/// assert_eq!(be(b"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15abcd"), Ok((&b"abcd"[..], 0x00010203040506070809101112131415)));
-/// assert_eq!(be(b"\x01"), Err(Err::Incomplete(Needed::new(15))));
-///
-/// named!(le<u128>, u128!(Endianness::Little));
-///
-/// assert_eq!(le(b"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15abcd"), Ok((&b"abcd"[..], 0x15141312111009080706050403020100)));
-/// assert_eq!(le(b"\x01"), Err(Err::Incomplete(Needed::new(15))));
-/// # }
-/// ```
-#[macro_export(local_inner_macros)]
-#[cfg(stable_i128)]
-macro_rules! u128 ( ($i:expr, $e:expr) => ( {if $crate::number::Endianness::Big == $e { $crate::number::streaming::be_u128($i) } else { $crate::number::streaming::le_u128($i) } } ););
-
-/// If the parameter is `nom::number::Endianness::Big`, parse a big endian i16 integer,
-/// otherwise a little endian i16 integer.
-///
-/// ```rust
-/// # #[macro_use] extern crate nom;
-/// # use nom::{Err, Needed};
-/// use nom::number::Endianness;
-///
-/// # fn main() {
-/// named!(be<i16>, i16!(Endianness::Big));
-///
-/// assert_eq!(be(b"\x00\x01abcd"), Ok((&b"abcd"[..], 0x0001)));
-/// assert_eq!(be(b"\x01"), Err(Err::Incomplete(Needed::new(1))));
-///
-/// named!(le<i16>, i16!(Endianness::Little));
-///
-/// assert_eq!(le(b"\x00\x01abcd"), Ok((&b"abcd"[..], 0x0100)));
-/// assert_eq!(le(b"\x01"), Err(Err::Incomplete(Needed::new(1))));
-/// # }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! i16 ( ($i:expr, $e:expr) => ( {if $crate::number::Endianness::Big == $e { $crate::number::streaming::be_i16($i) } else { $crate::number::streaming::le_i16($i) } } ););
-
-/// If the parameter is `nom::number::Endianness::Big`, parse a big endian i32 integer,
-/// otherwise a little endian i32 integer.
-///
-/// ```rust
-/// # #[macro_use] extern crate nom;
-/// # use nom::{Err, Needed};
-/// use nom::number::Endianness;
-///
-/// # fn main() {
-/// named!(be<i32>, i32!(Endianness::Big));
-///
-/// assert_eq!(be(b"\x00\x01\x02\x03abcd"), Ok((&b"abcd"[..], 0x00010203)));
-/// assert_eq!(be(b"\x01"), Err(Err::Incomplete(Needed::new(3))));
-///
-/// named!(le<i32>, i32!(Endianness::Little));
-///
-/// assert_eq!(le(b"\x00\x01\x02\x03abcd"), Ok((&b"abcd"[..], 0x03020100)));
-/// assert_eq!(le(b"\x01"), Err(Err::Incomplete(Needed::new(3))));
-/// # }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! i32 ( ($i:expr, $e:expr) => ( {if $crate::number::Endianness::Big == $e { $crate::number::streaming::be_i32($i) } else { $crate::number::streaming::le_i32($i) } } ););
-
-/// If the parameter is `nom::number::Endianness::Big`, parse a big endian i64 integer,
-/// otherwise a little endian i64 integer.
-///
-/// ```rust
-/// # #[macro_use] extern crate nom;
-/// # use nom::{Err, Needed};
-/// use nom::number::Endianness;
-///
-/// # fn main() {
-/// named!(be<i64>, i64!(Endianness::Big));
-///
-/// assert_eq!(be(b"\x00\x01\x02\x03\x04\x05\x06\x07abcd"), Ok((&b"abcd"[..], 0x0001020304050607)));
-/// assert_eq!(be(b"\x01"), Err(Err::Incomplete(Needed::new(7))));
-///
-/// named!(le<i64>, i64!(Endianness::Little));
-///
-/// assert_eq!(le(b"\x00\x01\x02\x03\x04\x05\x06\x07abcd"), Ok((&b"abcd"[..], 0x0706050403020100)));
-/// assert_eq!(le(b"\x01"), Err(Err::Incomplete(Needed::new(7))));
-/// # }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! i64 ( ($i:expr, $e:expr) => ( {if $crate::number::Endianness::Big == $e { $crate::number::streaming::be_i64($i) } else { $crate::number::streaming::le_i64($i) } } ););
-
-/// If the parameter is `nom::number::Endianness::Big`, parse a big endian i64 integer,
-/// otherwise a little endian i64 integer.
-///
-/// ```rust
-/// # #[macro_use] extern crate nom;
-/// # use nom::{Err, Needed};
-/// use nom::number::Endianness;
-///
-/// # fn main() {
-/// named!(be<i128>, i128!(Endianness::Big));
-///
-/// assert_eq!(be(b"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15abcd"), Ok((&b"abcd"[..], 0x00010203040506070809101112131415)));
-/// assert_eq!(be(b"\x01"), Err(Err::Incomplete(Needed::new(15))));
-///
-/// named!(le<i128>, i128!(Endianness::Little));
-///
-/// assert_eq!(le(b"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15abcd"), Ok((&b"abcd"[..], 0x15141312111009080706050403020100)));
-/// assert_eq!(le(b"\x01"), Err(Err::Incomplete(Needed::new(15))));
-/// # }
-/// ```
-#[macro_export(local_inner_macros)]
-#[cfg(stable_i128)]
-macro_rules! i128 ( ($i:expr, $e:expr) => ( {if $crate::number::Endianness::Big == $e { $crate::number::streaming::be_i128($i) } else { $crate::number::streaming::le_i128($i) } } ););
-
-#[cfg(test)]
-mod tests {
-  use crate::number::Endianness;
-
-  #[test]
-  fn configurable_endianness() {
-    named!(be_tst16<u16>, u16!(Endianness::Big));
-    named!(le_tst16<u16>, u16!(Endianness::Little));
-    assert_eq!(be_tst16(&[0x80, 0x00]), Ok((&b""[..], 32_768_u16)));
-    assert_eq!(le_tst16(&[0x80, 0x00]), Ok((&b""[..], 128_u16)));
-
-    named!(be_tst32<u32>, u32!(Endianness::Big));
-    named!(le_tst32<u32>, u32!(Endianness::Little));
-    assert_eq!(
-      be_tst32(&[0x12, 0x00, 0x60, 0x00]),
-      Ok((&b""[..], 302_014_464_u32))
-    );
-    assert_eq!(
-      le_tst32(&[0x12, 0x00, 0x60, 0x00]),
-      Ok((&b""[..], 6_291_474_u32))
-    );
-
-    named!(be_tst64<u64>, u64!(Endianness::Big));
-    named!(le_tst64<u64>, u64!(Endianness::Little));
-    assert_eq!(
-      be_tst64(&[0x12, 0x00, 0x60, 0x00, 0x12, 0x00, 0x80, 0x00]),
-      Ok((&b""[..], 1_297_142_246_100_992_000_u64))
-    );
-    assert_eq!(
-      le_tst64(&[0x12, 0x00, 0x60, 0x00, 0x12, 0x00, 0x80, 0x00]),
-      Ok((&b""[..], 36_028_874_334_666_770_u64))
-    );
-
-    named!(be_tsti16<i16>, i16!(Endianness::Big));
-    named!(le_tsti16<i16>, i16!(Endianness::Little));
-    assert_eq!(be_tsti16(&[0x00, 0x80]), Ok((&b""[..], 128_i16)));
-    assert_eq!(le_tsti16(&[0x00, 0x80]), Ok((&b""[..], -32_768_i16)));
-
-    named!(be_tsti32<i32>, i32!(Endianness::Big));
-    named!(le_tsti32<i32>, i32!(Endianness::Little));
-    assert_eq!(
-      be_tsti32(&[0x00, 0x12, 0x60, 0x00]),
-      Ok((&b""[..], 1_204_224_i32))
-    );
-    assert_eq!(
-      le_tsti32(&[0x00, 0x12, 0x60, 0x00]),
-      Ok((&b""[..], 6_296_064_i32))
-    );
-
-    named!(be_tsti64<i64>, i64!(Endianness::Big));
-    named!(le_tsti64<i64>, i64!(Endianness::Little));
-    assert_eq!(
-      be_tsti64(&[0x00, 0xFF, 0x60, 0x00, 0x12, 0x00, 0x80, 0x00]),
-      Ok((&b""[..], 71_881_672_479_506_432_i64))
-    );
-    assert_eq!(
-      le_tsti64(&[0x00, 0xFF, 0x60, 0x00, 0x12, 0x00, 0x80, 0x00]),
-      Ok((&b""[..], 36_028_874_334_732_032_i64))
-    );
-  }
-
-  //FIXME
-  /*
-  #[test]
-  #[cfg(feature = "std")]
-  fn manual_configurable_endianness_test() {
-    let x = 1;
-    let int_parse: Box<Fn(&[u8]) -> IResult<&[u8], u16, (&[u8], ErrorKind)>> = if x == 2 {
-      Box::new(be_u16)
-    } else {
-      Box::new(le_u16)
-    };
-    println!("{:?}", int_parse(&b"3"[..]));
-    assert_eq!(int_parse(&[0x80, 0x00]), Ok((&b""[..], 128_u16)));
-  }
-  */
-}
diff --git a/src/number/mod.rs b/src/number/mod.rs
index 6ab2cd5..58c3d51 100644
--- a/src/number/mod.rs
+++ b/src/number/mod.rs
@@ -1,8 +1,5 @@
 //! Parsers recognizing numbers
 
-#[macro_use]
-mod macros;
-
 pub mod complete;
 pub mod streaming;
 
diff --git a/src/number/streaming.rs b/src/number/streaming.rs
index f502519..5d62685 100644
--- a/src/number/streaming.rs
+++ b/src/number/streaming.rs
@@ -1983,4 +1983,87 @@ mod tests {
       Err(Err::Incomplete(Needed::new(1)))
     );
   }
+
+  #[test]
+  fn configurable_endianness() {
+    use crate::number::Endianness;
+
+    fn be_tst16(i: &[u8]) -> IResult<&[u8], u16> {
+      u16(Endianness::Big)(i)
+    }
+    fn le_tst16(i: &[u8]) -> IResult<&[u8], u16> {
+      u16(Endianness::Little)(i)
+    }
+    assert_eq!(be_tst16(&[0x80, 0x00]), Ok((&b""[..], 32_768_u16)));
+    assert_eq!(le_tst16(&[0x80, 0x00]), Ok((&b""[..], 128_u16)));
+
+    fn be_tst32(i: &[u8]) -> IResult<&[u8], u32> {
+      u32(Endianness::Big)(i)
+    }
+    fn le_tst32(i: &[u8]) -> IResult<&[u8], u32> {
+      u32(Endianness::Little)(i)
+    }
+    assert_eq!(
+      be_tst32(&[0x12, 0x00, 0x60, 0x00]),
+      Ok((&b""[..], 302_014_464_u32))
+    );
+    assert_eq!(
+      le_tst32(&[0x12, 0x00, 0x60, 0x00]),
+      Ok((&b""[..], 6_291_474_u32))
+    );
+
+    fn be_tst64(i: &[u8]) -> IResult<&[u8], u64> {
+      u64(Endianness::Big)(i)
+    }
+    fn le_tst64(i: &[u8]) -> IResult<&[u8], u64> {
+      u64(Endianness::Little)(i)
+    }
+    assert_eq!(
+      be_tst64(&[0x12, 0x00, 0x60, 0x00, 0x12, 0x00, 0x80, 0x00]),
+      Ok((&b""[..], 1_297_142_246_100_992_000_u64))
+    );
+    assert_eq!(
+      le_tst64(&[0x12, 0x00, 0x60, 0x00, 0x12, 0x00, 0x80, 0x00]),
+      Ok((&b""[..], 36_028_874_334_666_770_u64))
+    );
+
+    fn be_tsti16(i: &[u8]) -> IResult<&[u8], i16> {
+      i16(Endianness::Big)(i)
+    }
+    fn le_tsti16(i: &[u8]) -> IResult<&[u8], i16> {
+      i16(Endianness::Little)(i)
+    }
+    assert_eq!(be_tsti16(&[0x00, 0x80]), Ok((&b""[..], 128_i16)));
+    assert_eq!(le_tsti16(&[0x00, 0x80]), Ok((&b""[..], -32_768_i16)));
+
+    fn be_tsti32(i: &[u8]) -> IResult<&[u8], i32> {
+      i32(Endianness::Big)(i)
+    }
+    fn le_tsti32(i: &[u8]) -> IResult<&[u8], i32> {
+      i32(Endianness::Little)(i)
+    }
+    assert_eq!(
+      be_tsti32(&[0x00, 0x12, 0x60, 0x00]),
+      Ok((&b""[..], 1_204_224_i32))
+    );
+    assert_eq!(
+      le_tsti32(&[0x00, 0x12, 0x60, 0x00]),
+      Ok((&b""[..], 6_296_064_i32))
+    );
+
+    fn be_tsti64(i: &[u8]) -> IResult<&[u8], i64> {
+      i64(Endianness::Big)(i)
+    }
+    fn le_tsti64(i: &[u8]) -> IResult<&[u8], i64> {
+      i64(Endianness::Little)(i)
+    }
+    assert_eq!(
+      be_tsti64(&[0x00, 0xFF, 0x60, 0x00, 0x12, 0x00, 0x80, 0x00]),
+      Ok((&b""[..], 71_881_672_479_506_432_i64))
+    );
+    assert_eq!(
+      le_tsti64(&[0x00, 0xFF, 0x60, 0x00, 0x12, 0x00, 0x80, 0x00]),
+      Ok((&b""[..], 36_028_874_334_732_032_i64))
+    );
+  }
 }
diff --git a/src/str.rs b/src/str.rs
index 444c962..a5e8186 100644
--- a/src/str.rs
+++ b/src/str.rs
@@ -1,12 +1,11 @@
 #[cfg(test)]
 mod test {
+  #[cfg(feature = "alloc")]
+  use crate::{branch::alt, bytes::complete::tag_no_case, combinator::recognize, multi::many1};
   use crate::{
-      Err, IResult,
-      error::{self, ErrorKind},
-      bytes::complete::tag,
-      branch::alt,
-      combinator::recognize,
-      multi::many1,
+    Err, IResult,
+    error::{self, ErrorKind},
+    bytes::complete::{is_a, is_not, tag, take, take_till, take_until},
   };
 
   #[test]
@@ -14,7 +13,7 @@ mod test {
     const INPUT: &str = "Hello World!";
     const TAG: &str = "Hello";
     fn test(input: &str) -> IResult<&str, &str> {
-      tag!(input, TAG)
+      tag(TAG)(input)
     }
 
     match test(INPUT) {
@@ -38,10 +37,12 @@ mod test {
 
   #[test]
   fn tagtr_incomplete() {
+    use crate::bytes::streaming::tag;
+
     const INPUT: &str = "Hello";
     const TAG: &str = "Hello World!";
 
-    let res: IResult<_, _, error::Error<_>> = tag!(INPUT, TAG);
+    let res: IResult<_, _, error::Error<_>> = tag(TAG)(INPUT);
     match res {
       Err(Err::Incomplete(_)) => (),
       other => {
@@ -59,7 +60,7 @@ mod test {
     const INPUT: &str = "Hello World!";
     const TAG: &str = "Random"; // TAG must be closer than INPUT.
 
-    let res: IResult<_, _, error::Error<_>> = tag!(INPUT, TAG);
+    let res: IResult<_, _, error::Error<_>> = tag(TAG)(INPUT);
     match res {
       Err(Err::Error(_)) => (),
       other => {
@@ -77,7 +78,7 @@ mod test {
     const CONSUMED: &str = "βèƒôřèÂßÇ";
     const LEFTOVER: &str = "áƒƭèř";
 
-    let res: IResult<_, _, error::Error<_>> = take!(INPUT, 9);
+    let res: IResult<_, _, error::Error<_>> = take(9_usize)(INPUT);
     match res {
       Ok((extra, output)) => {
         assert!(
@@ -107,7 +108,7 @@ mod test {
     const CONSUMED: &str = "βèƒôřè";
     const LEFTOVER: &str = "ÂßÇ∂áƒƭèř";
 
-    let res: IResult<_, _, (_, ErrorKind)> = take_until!(INPUT, FIND);
+    let res: IResult<_, _, (_, ErrorKind)> = take_until(FIND)(INPUT);
     match res {
       Ok((extra, output)) => {
         assert!(
@@ -134,9 +135,11 @@ mod test {
 
   #[test]
   fn take_s_incomplete() {
+    use crate::bytes::streaming::take;
+
     const INPUT: &str = "βèƒôřèÂßÇá";
 
-    let res: IResult<_, _, (_, ErrorKind)> = take!(INPUT, 13);
+    let res: IResult<_, _, (_, ErrorKind)> = take(13_usize)(INPUT);
     match res {
       Err(Err::Incomplete(_)) => (),
       other => panic!(
@@ -155,7 +158,11 @@ mod test {
 
   #[test]
   fn take_while() {
-    named!(f<&str,&str>, take_while!(is_alphabetic));
+    use crate::bytes::streaming::take_while;
+
+    fn f(i: &str) -> IResult<&str, &str> {
+      take_while(is_alphabetic)(i)
+    }
     let a = "";
     let b = "abcd";
     let c = "abcd123";
@@ -169,7 +176,11 @@ mod test {
 
   #[test]
   fn take_while1() {
-    named!(f<&str,&str>, take_while1!(is_alphabetic));
+    use crate::bytes::streaming::take_while1;
+
+    fn f(i: &str) -> IResult<&str, &str> {
+      take_while1(is_alphabetic)(i)
+    }
     let a = "";
     let b = "abcd";
     let c = "abcd123";
@@ -193,7 +204,7 @@ mod test {
       c == 'á'
     }
     fn test(input: &str) -> IResult<&str, &str> {
-      take_till!(input, till_s)
+      take_till(till_s)(input)
     }
     match test(INPUT) {
       Ok((extra, output)) => {
@@ -219,6 +230,8 @@ mod test {
 
   #[test]
   fn take_while_succeed_none() {
+    use crate::bytes::complete::take_while;
+
     const INPUT: &str = "βèƒôřèÂßÇáƒƭèř";
     const CONSUMED: &str = "";
     const LEFTOVER: &str = "βèƒôřèÂßÇáƒƭèř";
@@ -226,7 +239,7 @@ mod test {
       c == '9'
     }
     fn test(input: &str) -> IResult<&str, &str> {
-      take_while!(input, while_s)
+      take_while(while_s)(input)
     }
     match test(INPUT) {
       Ok((extra, output)) => {
@@ -257,7 +270,7 @@ mod test {
     const CONSUMED: &str = "βèƒôřèÂßÇ";
     const LEFTOVER: &str = "áƒƭèř";
     fn test(input: &str) -> IResult<&str, &str> {
-      is_not!(input, AVOID)
+      is_not(AVOID)(input)
     }
     match test(INPUT) {
       Ok((extra, output)) => {
@@ -283,6 +296,8 @@ mod test {
 
   #[test]
   fn take_while_succeed_some() {
+    use crate::bytes::complete::take_while;
+
     const INPUT: &str = "βèƒôřèÂßÇáƒƭèř";
     const CONSUMED: &str = "βèƒôřèÂßÇ";
     const LEFTOVER: &str = "áƒƭèř";
@@ -298,7 +313,7 @@ mod test {
         || c == 'Ç'
     }
     fn test(input: &str) -> IResult<&str, &str> {
-      take_while!(input, while_s)
+      take_while(while_s)(input)
     }
     match test(INPUT) {
       Ok((extra, output)) => {
@@ -327,7 +342,7 @@ mod test {
     const INPUT: &str = "βèƒôřèÂßÇáƒƭèř";
     const AVOID: &str = "βúçƙ¥";
     fn test(input: &str) -> IResult<&str, &str> {
-      is_not!(input, AVOID)
+      is_not(AVOID)(input)
     }
     match test(INPUT) {
       Err(Err::Error(_)) => (),
@@ -340,6 +355,8 @@ mod test {
 
   #[test]
   fn take_while1_succeed() {
+    use crate::bytes::complete::take_while1;
+
     const INPUT: &str = "βèƒôřèÂßÇáƒƭèř";
     const CONSUMED: &str = "βèƒôřèÂßÇ";
     const LEFTOVER: &str = "áƒƭèř";
@@ -355,7 +372,7 @@ mod test {
         || c == 'Ç'
     }
     fn test(input: &str) -> IResult<&str, &str> {
-      take_while1!(input, while1_s)
+      take_while1(while1_s)(input)
     }
     match test(INPUT) {
       Ok((extra, output)) => {
@@ -381,10 +398,12 @@ mod test {
 
   #[test]
   fn take_until_incomplete() {
+    use crate::bytes::streaming::take_until;
+
     const INPUT: &str = "βèƒôřè";
     const FIND: &str = "βèƒôřèÂßÇ";
 
-    let res: IResult<_, _, (_, ErrorKind)> = take_until!(INPUT, FIND);
+    let res: IResult<_, _, (_, ErrorKind)> = take_until(FIND)(INPUT);
     match res {
       Err(Err::Incomplete(_)) => (),
       other => panic!(
@@ -402,7 +421,7 @@ mod test {
     const CONSUMED: &str = "βèƒôřèÂßÇ";
     const LEFTOVER: &str = "áƒƭèř";
     fn test(input: &str) -> IResult<&str, &str> {
-      is_a!(input, MATCH)
+      is_a(MATCH)(input)
     }
     match test(INPUT) {
       Ok((extra, output)) => {
@@ -428,12 +447,14 @@ mod test {
 
   #[test]
   fn take_while1_fail() {
+    use crate::bytes::complete::take_while1;
+
     const INPUT: &str = "βèƒôřèÂßÇáƒƭèř";
     fn while1_s(c: char) -> bool {
       c == '9'
     }
     fn test(input: &str) -> IResult<&str, &str> {
-      take_while1!(input, while1_s)
+      take_while1(while1_s)(input)
     }
     match test(INPUT) {
       Err(Err::Error(_)) => (),
@@ -450,7 +471,7 @@ mod test {
     const INPUT: &str = "βèƒôřèÂßÇáƒƭèř";
     const MATCH: &str = "Ûñℓúçƙ¥";
     fn test(input: &str) -> IResult<&str, &str> {
-      is_a!(input, MATCH)
+      is_a(MATCH)(input)
     }
     match test(INPUT) {
       Err(Err::Error(_)) => (),
@@ -463,10 +484,12 @@ mod test {
 
   #[test]
   fn take_until_error() {
+    use crate::bytes::streaming::take_until;
+
     const INPUT: &str = "βèƒôřèÂßÇáƒƭèř";
     const FIND: &str = "Ráñδô₥";
 
-    let res: IResult<_, _, (_, ErrorKind)> = take_until!(INPUT, FIND);
+    let res: IResult<_, _, (_, ErrorKind)> = take_until(FIND)(INPUT);
     match res {
       Err(Err::Incomplete(_)) => (),
       other => panic!(
@@ -486,7 +509,6 @@ mod test {
     fn f(i: &str) -> IResult<&str, &str> {
         recognize(many1(alt((tag("a"), tag("b")))))(i)
     }
-    //named!(f <&str,&str>, recognize!(many1!(complete!(alt!( tag!("a") | tag!("b") )))));
 
     assert_eq!(f(&a[..]), Ok((&a[6..], &a[..])));
     assert_eq!(f(&b[..]), Ok((&b[4..], &b[..4])));
@@ -494,9 +516,9 @@ mod test {
 
   #[test]
   fn utf8_indexing() {
-    named!(dot(&str) -> &str,
-      tag!(".")
-    );
+    fn dot(i: &str) -> IResult<&str, &str> {
+      tag(".")(i)
+    }
 
     let _ = dot("點");
   }
@@ -504,14 +526,11 @@ mod test {
   #[cfg(feature = "alloc")]
   #[test]
   fn case_insensitive() {
-    named!(test<&str,&str>, tag_no_case!("ABcd"));
+    fn test(i: &str) -> IResult<&str, &str> {
+      tag_no_case("ABcd")(i)
+    }
     assert_eq!(test("aBCdefgh"), Ok(("efgh", "aBCd")));
     assert_eq!(test("abcdefgh"), Ok(("efgh", "abcd")));
     assert_eq!(test("ABCDefgh"), Ok(("efgh", "ABCD")));
-
-    named!(test2<&str,&str>, tag_no_case!("ABcd"));
-    assert_eq!(test2("aBCdefgh"), Ok(("efgh", "aBCd")));
-    assert_eq!(test2("abcdefgh"), Ok(("efgh", "abcd")));
-    assert_eq!(test2("ABCDefgh"), Ok(("efgh", "ABCD")));
   }
 }


Test patch:
diff --git a/src/branch/tests.rs b/src/branch/tests.rs
index 2cebd86..ecd4440 100644
--- a/src/branch/tests.rs
+++ b/src/branch/tests.rs
@@ -1,9 +1,9 @@
+use crate::branch::{alt, permutation};
+use crate::bytes::streaming::tag;
 use crate::error::ErrorKind;
 use crate::internal::{Err, IResult, Needed};
 #[cfg(feature = "alloc")]
 use crate::{
-  branch::{alt, permutation},
-  bytes::streaming::tag,
   error::ParseError,
   lib::std::{
     fmt::Debug,
diff --git a/src/multi/tests.rs b/src/multi/tests.rs
index 3c02873..8c3a2d0 100644
--- a/src/multi/tests.rs
+++ b/src/multi/tests.rs
@@ -1,9 +1,4 @@
-use super::{
-  count, fold_many0, fold_many1, fold_many_m_n, length_count, length_data, length_value, many0,
-  many0_count, many1, many1_count, many_m_n, many_till, separated_list0, separated_list1,
-};
-#[cfg(feature = "alloc")]
-use crate::lib::std::vec::Vec;
+use super::{length_data, length_value, many0_count, many1_count};
 use crate::{
   bytes::streaming::tag,
   character::streaming::digit1 as digit,
@@ -13,6 +8,14 @@ use crate::{
   number::streaming::{be_u16, be_u8},
   sequence::{pair, tuple},
 };
+#[cfg(feature = "alloc")]
+use crate::{
+  lib::std::vec::Vec,
+  multi::{
+    count, length_count, fold_many0, fold_many1, fold_many_m_n, many0, many1, many_m_n, many_till,
+    separated_list0, separated_list1,
+  },
+};
 
 #[test]
 #[cfg(feature = "alloc")]
diff --git a/tests/custom_errors.rs b/tests/custom_errors.rs
index ad14ee5..2021713 100644
--- a/tests/custom_errors.rs
+++ b/tests/custom_errors.rs
@@ -1,15 +1,14 @@
 #![allow(dead_code)]
-#![cfg_attr(feature = "cargo-clippy", allow(block_in_if_condition_stmt))]
-
-#[macro_use]
-extern crate nom;
 
+use nom::bytes::streaming::tag;
 use nom::character::streaming::digit1 as digit;
+use nom::combinator::verify;
 use nom::error::{ErrorKind, ParseError};
+#[cfg(feature = "alloc")]
+use nom::multi::count;
+use nom::sequence::terminated;
 use nom::IResult;
 
-use std::convert::From;
-
 #[derive(Debug)]
 pub struct CustomError(String);
 
@@ -31,19 +30,19 @@ impl<'a> ParseError<&'a str> for CustomError {
 
 fn test1(input: &str) -> IResult<&str, &str, CustomError> {
   //fix_error!(input, CustomError, tag!("abcd"))
-  tag!(input, "abcd")
+  tag("abcd")(input)
 }
 
 fn test2(input: &str) -> IResult<&str, &str, CustomError> {
   //terminated!(input, test1, fix_error!(CustomError, digit))
-  terminated!(input, test1, digit)
+  terminated(test1, digit)(input)
 }
 
 fn test3(input: &str) -> IResult<&str, &str, CustomError> {
-  verify!(input, test1, |s: &str| { s.starts_with("abcd") })
+  verify(test1, |s: &str| s.starts_with("abcd"))(input)
 }
 
 #[cfg(feature = "alloc")]
 fn test4(input: &str) -> IResult<&str, Vec<&str>, CustomError> {
-  count!(input, test1, 4)
+  count(test1, 4)(input)
 }
diff --git a/tests/inference.rs b/tests/inference.rs
deleted file mode 100644
index 4555d7a..0000000
--- a/tests/inference.rs
+++ /dev/null
@@ -1,54 +0,0 @@
-//! test type inference issues in parsee compilation
-//#![feature(trace_macros)]
-#![allow(dead_code)]
-#![allow(unused_comparisons)]
-#![allow(unused_variables)]
-#![allow(unused_imports)]
-
-#[macro_use]
-extern crate nom;
-
-use nom::character::{is_digit, streaming::alpha1 as alpha};
-use std::str;
-
-// issue #617
-named!(multi<&[u8], () >, fold_many0!( take_while1!( is_digit ), (), |_, _| {}));
-
-// issue #561
-#[cfg(feature = "alloc")]
-named!(
-  value<Vec<Vec<&str>>>,
-  do_parse!(
-    first_line: map_res!(is_not!("\n"), std::str::from_utf8)
-      >> rest:
-        many_m_n!(
-          0,
-          1,
-          separated_list0!(
-            tag!("\n\t"),
-            map_res!(take_while!(call!(|c| c != b'\n')), std::str::from_utf8)
-          )
-        )
-      >> (rest)
-  )
-);
-
-// issue #534
-#[cfg(feature = "alloc")]
-fn wrap_suffix(input: &Option<Vec<&[u8]>>) -> Option<String> {
-  if input.is_some() {
-    // I've tried both of the lines below individually and get the same error.
-    Some("hello".to_string())
-  //Some(str::from_utf8(u).expect("Found invalid UTF-8").to_string())
-  } else {
-    None
-  }
-}
-
-#[cfg(feature = "alloc")]
-named!(parse_suffix<&[u8],Option<String>>,do_parse!(
-  u: opt!(many1!(alt!(
-    complete!(tag!("%")) | complete!(tag!("#"))  | complete!(tag!("@")) | complete!(alpha)
-  ))) >>
-  (wrap_suffix(&u))
-));
diff --git a/tests/issues.rs b/tests/issues.rs
index 3ffc271..b9c41e9 100644
--- a/tests/issues.rs
+++ b/tests/issues.rs
@@ -2,15 +2,7 @@
 #![allow(dead_code)]
 #![cfg_attr(feature = "cargo-clippy", allow(redundant_closure))]
 
-#[macro_use]
-extern crate nom;
-
-use nom::{
-  character::{is_digit, streaming::space1 as space},
-  error::ErrorKind,
-  number::streaming::le_u64,
-  Err, IResult, Needed,
-};
+use nom::{error::ErrorKind, Err, IResult, Needed};
 
 #[allow(dead_code)]
 struct Range {
@@ -26,78 +18,36 @@ pub fn take_char(input: &[u8]) -> IResult<&[u8], char> {
   }
 }
 
-//trace_macros!(true);
-
-#[allow(dead_code)]
-named!(range<&[u8], Range>,
-    alt!(
-        do_parse!(
-            start: take_char >>
-            tag!("-")        >>
-            end: take_char   >>
-            (Range {
-                start: start,
-                end:   end,
-            })
-        ) |
-        map!(
-            take_char,
-            |c| {
-                Range {
-                    start: c,
-                    end:   c,
-                }
-            }
-        )
-    )
-);
-
-#[allow(dead_code)]
-named!(literal<&[u8], Vec<char> >,
-    map!(
-        many1!(take_char),
-        |cs| {
-          cs
-        }
-    )
-);
-
-#[test]
-fn issue_58() {
-  let _ = range(&b"abcd"[..]);
-  let _ = literal(&b"abcd"[..]);
-}
-
-//trace_macros!(false);
-
 #[cfg(feature = "std")]
 mod parse_int {
   use nom::HexDisplay;
   use nom::{
     character::streaming::{digit1 as digit, space1 as space},
+    combinator::{complete, map, opt},
+    multi::many0,
     IResult,
   };
   use std::str;
 
-  named!(parse_ints<Vec<i32>>, many0!(spaces_or_int));
+  fn parse_ints(input: &[u8]) -> IResult<&[u8], Vec<i32>> {
+    many0(spaces_or_int)(input)
+  }
 
   fn spaces_or_int(input: &[u8]) -> IResult<&[u8], i32> {
     println!("{}", input.to_hex(8));
-    do_parse!(
-      input,
-      opt!(complete!(space))
-        >> res: map!(complete!(digit), |x| {
-          println!("x: {:?}", x);
-          let result = str::from_utf8(x).unwrap();
-          println!("Result: {}", result);
-          println!("int is empty?: {}", x.is_empty());
-          match result.parse() {
-            Ok(i) => i,
-            Err(e) => panic!("UH OH! NOT A DIGIT! {:?}", e),
-          }
-        })
-        >> (res)
-    )
+    let (i, _) = opt(complete(space))(input)?;
+    let (i, res) = map(complete(digit), |x| {
+      println!("x: {:?}", x);
+      let result = str::from_utf8(x).unwrap();
+      println!("Result: {}", result);
+      println!("int is empty?: {}", x.is_empty());
+      match result.parse() {
+        Ok(i) => i,
+        Err(e) => panic!("UH OH! NOT A DIGIT! {:?}", e),
+      }
+    })(i)?;
+
+    Ok((i, res))
   }
 
   #[test]
@@ -114,67 +64,34 @@ mod parse_int {
 
 #[test]
 fn usize_length_bytes_issue() {
+  use nom::multi::length_data;
   use nom::number::streaming::be_u16;
-  let _: IResult<&[u8], &[u8], (&[u8], ErrorKind)> = length_data!(b"012346", be_u16);
-}
-
-/*
- DOES NOT COMPILE
-#[test]
-fn issue_152() {
-  named!(take4, take!(4));
-  named!(xyz, tag!("XYZ"));
-  named!(abc, tag!("abc"));
-
-
-  named!(sw,
-    switch!(take4,
-      b"abcd" => xyz |
-      b"efgh" => abc
-    )
-  );
+  let _: IResult<&[u8], &[u8], (&[u8], ErrorKind)> = length_data(be_u16)(b"012346");
 }
-*/
 
 #[test]
 fn take_till_issue() {
-  named!(nothing, take_till!(call!(|_| true)));
+  use nom::bytes::streaming::take_till;
+
+  fn nothing(i: &[u8]) -> IResult<&[u8], &[u8]> {
+    take_till(|_| true)(i)
+  }
 
   assert_eq!(nothing(b""), Err(Err::Incomplete(Needed::new(1))));
   assert_eq!(nothing(b"abc"), Ok((&b"abc"[..], &b""[..])));
 }
 
-named!(
-  issue_498<Vec<&[u8]>>,
-  separated_list1!(opt!(space), tag!("abcd"))
-);
-
-named!(issue_308(&str) -> bool,
-    do_parse! (
-        tag! ("foo") >>
-        b: alt! (
-            complete!(map! (tag! ("1"), |_: &str|->bool {true})) |
-            value! (false)
-        ) >>
-        (b) ));
-
-#[cfg(feature = "alloc")]
-fn issue_302(input: &[u8]) -> IResult<&[u8], Option<Vec<u64>>> {
-  do_parse!(input, entries: cond!(true, count!(le_u64, 3)) >> (entries))
-}
-
 #[test]
 fn issue_655() {
   use nom::character::streaming::{line_ending, not_line_ending};
-  named!(twolines(&str) -> (&str, &str),
-    do_parse!(
-      l1 : not_line_ending >>
-           line_ending >>
-      l2 : not_line_ending >>
-           line_ending >>
-      ((l1, l2))
-    )
-  );
+  fn twolines(i: &str) -> IResult<&str, (&str, &str)> {
+    let (i, l1) = not_line_ending(i)?;
+    let (i, _) = line_ending(i)?;
+    let (i, l2) = not_line_ending(i)?;
+    let (i, _) = line_ending(i)?;
+
+    Ok((i, (l1, l2)))
+  }
 
   assert_eq!(twolines("foo\nbar\n"), Ok(("", ("foo", "bar"))));
   assert_eq!(twolines("féo\nbar\n"), Ok(("", ("féo", "bar"))));
@@ -182,79 +99,19 @@ fn issue_655() {
   assert_eq!(twolines("foé\r\nbar\n"), Ok(("", ("foé", "bar"))));
 }
 
-#[test]
-fn issue_721() {
-  named!(f1<&str, u16>, parse_to!(u16));
-  named!(f2<&str, String>, parse_to!(String));
-  assert_eq!(f1("1234"), Ok(("", 1234)));
-  assert_eq!(f2("foo"), Ok(("", "foo".to_string())));
-  //assert_eq!(parse_to!("1234", u16), Ok(("", 1234)));
-  //assert_eq!(parse_to!("foo", String), Ok(("", "foo".to_string())));
-}
-
 #[cfg(feature = "alloc")]
-named!(issue_717<&[u8], Vec<&[u8]> >,
-  separated_list0!(tag!([0x0]), is_not!([0x0u8]))
-);
-
-struct NoPartialEq {
-  value: i32,
-}
-
-named!(issue_724<&str, i32>,
-  do_parse!(
-    metadata: permutation!(
-      map!(tag!("hello"), |_| NoPartialEq { value: 1 }),
-      map!(tag!("world"), |_| NoPartialEq { value: 2 })
-    ) >>
-    (metadata.0.value + metadata.1.value)
-  )
-);
-
-#[test]
-fn issue_752() {
-  assert_eq!(
-    Err::Error(("ab", nom::error::ErrorKind::ParseTo)),
-    parse_to!("ab", usize).unwrap_err()
-  )
-}
-
-fn atom_specials(c: u8) -> bool {
-  c == b'q'
-}
-
-named!(
-  capability<&str>,
-  do_parse!(tag!(" ") >> _atom: map_res!(take_till1!(atom_specials), std::str::from_utf8) >> ("a"))
-);
+fn issue_717(i: &[u8]) -> IResult<&[u8], Vec<&[u8]>> {
+  use nom::bytes::complete::{is_not, tag};
+  use nom::multi::separated_list0;
 
-#[test]
-fn issue_759() {
-  assert_eq!(capability(b" abcqd"), Ok((&b"qd"[..], "a")));
+  separated_list0(tag([0x0]), is_not([0x0u8]))(i)
 }
 
-named_args!(issue_771(count: usize)<Vec<u32>>,
-  length_count!(value!(count), call!(nom::number::streaming::be_u32))
-);
-
-/// This test is in a separate module to check that all required symbols are imported in
-/// `escaped_transform!()`. Without the module, the `use`-es of the current module would
-/// mask the error ('"Use of undeclared type or module `Needed`" in escaped_transform!').
-mod issue_780 {
-  named!(issue_780<&str, String>,
-    escaped_transform!(call!(::nom::character::streaming::alpha1), '\\', tag!("n"))
-  );
-}
-
-// issue 617
-named!(digits, take_while1!(is_digit));
-named!(multi_617<&[u8], () >, fold_many0!( digits, (), |_, _| {}));
-
-// Sad :(
-named!(multi_617_fails<&[u8], () >, fold_many0!( take_while1!( is_digit ), (), |_, _| {}));
-
 mod issue_647 {
-  use nom::{error::Error, number::streaming::be_f64, Err};
+  use nom::bytes::streaming::tag;
+  use nom::combinator::complete;
+  use nom::multi::separated_list0;
+  use nom::{error::Error, number::streaming::be_f64, Err, IResult};
   pub type Input<'a> = &'a [u8];
 
   #[derive(PartialEq, Debug, Clone)]
@@ -267,33 +124,31 @@ mod issue_647 {
     input: Input<'a>,
     _cs: &'b f64,
   ) -> Result<(Input<'a>, Vec<f64>), Err<Error<&'a [u8]>>> {
-    separated_list0!(input, complete!(tag!(",")), complete!(be_f64))
+    separated_list0(complete(tag(",")), complete(be_f64))(input)
   }
 
-  named!(data<Input,Data>, map!(
-      do_parse!(
-          c: be_f64 >>
-          tag!("\n") >>
-          v: call!(list,&c) >>
-          (c,v)
-      ), |(c,v)| {
-          Data {
-              c: c,
-              v: v
-          }
-      }
-  ));
+  fn data(input: Input<'_>) -> IResult<Input<'_>, Data> {
+    let (i, c) = be_f64(input)?;
+    let (i, _) = tag("\n")(i)?;
+    let (i, v) = list(i, &c)?;
+    Ok((i, Data { c, v }))
+  }
 }
 
-named!(issue_775, take_till1!(|_| true));
-
 #[test]
 fn issue_848_overflow_incomplete_bits_to_bytes() {
-  named!(take, take!(0x2000000000000000));
-  named!(parser<&[u8], &[u8]>, bits!(bytes!(take)));
+  fn take(i: &[u8]) -> IResult<&[u8], &[u8]> {
+    use nom::bytes::streaming::take;
+    take(0x2000000000000000_usize)(i)
+  }
+  fn parser(i: &[u8]) -> IResult<&[u8], &[u8]> {
+    use nom::bits::{bits, bytes};
+
+    bits(bytes(take))(i)
+  }
   assert_eq!(
     parser(&b""[..]),
-    Err(Err::Failure(error_position!(&b""[..], ErrorKind::TooLarge)))
+    Err(Err::Failure(nom::error_position!(&b""[..], ErrorKind::TooLarge)))
   );
 }
 
@@ -338,16 +193,6 @@ fn issue_1027_convert_error_panic_nonempty() {
   );
 }
 
-named!(issue_962<&[u8], Vec<&[u8]>>,
-    fold_many0!(
-        alt!(tag!("aaaa") | tag!("bbbb")),
-        Vec::new(), |mut acc: Vec<_>, item| {
-            acc.push(item);
-            acc
-        }
-    )
-);
-
 #[test]
 fn issue_1231_bits_expect_fn_closure() {
   use nom::bits::{bits, complete::take};
diff --git a/tests/named_args.rs b/tests/named_args.rs
deleted file mode 100644
index 9ba4b3a..0000000
--- a/tests/named_args.rs
+++ /dev/null
@@ -1,122 +0,0 @@
-#[macro_use]
-extern crate nom;
-
-use nom::{
-  branch::alt,
-  bytes::complete::tag,
-  character::complete::{digit1 as digit, space0 as space},
-  sequence::{delimited, pair, preceded},
-};
-
-// Parser definition
-
-use std::str;
-use std::str::FromStr;
-
-use self::Operator::*;
-
-enum Operator {
-  Slash,
-  Star,
-}
-
-impl Operator {
-  fn to_str(&self) -> &'static str {
-    match *self {
-      Slash => "/",
-      Star => "*",
-    }
-  }
-}
-
-// Parse the specified `Operator`.
-named_args!(operator(op: Operator) <&[u8], &[u8]>,
-    call!(tag(op.to_str()))
-);
-
-// We parse any expr surrounded by the tags `open_tag` and `close_tag`, ignoring all whitespaces around those
-named_args!(brackets<'a>(open_tag: &str, close_tag: &str) <&'a[u8], i64>,
-  call!(delimited(
-    space,
-    delimited(tag(open_tag), preceded(space, expr), preceded(space, tag(close_tag))),
-    space
-  ))
-);
-
-fn byte_slice_to_str<'a>(s: &'a [u8]) -> Result<&'a str, str::Utf8Error> {
-  str::from_utf8(s)
-}
-
-// We transform an integer string into a i64, ignoring surrounding whitespaces
-// We look for a digit suite, and try to convert it.
-// If either str::from_utf8 or FromStr::from_str fail,
-// we fallback to the brackets parser defined above
-named!(factor<&[u8], i64>, alt!(
-    map_res!(
-      map_res!(
-        call!(delimited(space, digit, space)),
-        byte_slice_to_str
-      ),
-      FromStr::from_str
-    )
-  | call!(brackets, "(", ")")
-  )
-);
-
-// We read an initial factor and for each time we find
-// a * or / operator followed by another factor, we do
-// the math by folding everything
-named!(term <&[u8], i64>, do_parse!(
-    init: factor >>
-    res:  fold_many0!(
-        pair!(alt!(call!(operator, Star) | call!(operator, Slash)), factor),
-        init,
-        |acc, (op, val): (&[u8], i64)| {
-            if (op[0] as char) == '*' { acc * val } else { acc / val }
-        }
-    ) >>
-    (res)
-  )
-);
-
-named!(expr <&[u8], i64>, do_parse!(
-    init: term >>
-    res:  fold_many0!(
-        call!(pair(alt((tag("+"), tag("-"))), term)),
-        init,
-        |acc, (op, val): (&[u8], i64)| {
-            if (op[0] as char) == '+' { acc + val } else { acc - val }
-        }
-    ) >>
-    (res)
-  )
-);
-
-#[test]
-fn factor_test() {
-  assert_eq!(factor(&b"3"[..]), Ok((&b""[..], 3)));
-  assert_eq!(factor(&b" 12"[..]), Ok((&b""[..], 12)));
-  assert_eq!(factor(&b"537  "[..]), Ok((&b""[..], 537)));
-  assert_eq!(factor(&b"  24   "[..]), Ok((&b""[..], 24)));
-}
-
-#[test]
-fn term_test() {
-  assert_eq!(term(&b" 12 *2 /  3"[..]), Ok((&b""[..], 8)));
-  assert_eq!(term(&b" 2* 3  *2 *2 /  3"[..]), Ok((&b""[..], 8)));
-  assert_eq!(term(&b" 48 /  3/2"[..]), Ok((&b""[..], 8)));
-}
-
-#[test]
-fn expr_test() {
-  assert_eq!(expr(&b" 1 +  2 "[..]), Ok((&b""[..], 3)));
-  assert_eq!(expr(&b" 12 + 6 - 4+  3"[..]), Ok((&b""[..], 17)));
-  assert_eq!(expr(&b" 1 + 2*3 + 4"[..]), Ok((&b""[..], 11)));
-}
-
-#[test]
-fn parens_test() {
-  assert_eq!(expr(&b" (  2 )"[..]), Ok((&b""[..], 2)));
-  assert_eq!(expr(&b" 2* (  3 + 4 ) "[..]), Ok((&b""[..], 14)));
-  assert_eq!(expr(&b"  2*2 / ( 5 - 1) + 3"[..]), Ok((&b""[..], 4)));
-}
diff --git a/tests/reborrow_fold.rs b/tests/reborrow_fold.rs
index b53555b..d356176 100644
--- a/tests/reborrow_fold.rs
+++ b/tests/reborrow_fold.rs
@@ -1,18 +1,31 @@
 #![allow(dead_code)]
-#![allow(unused_variables)]
-
-#[macro_use]
-extern crate nom;
+// #![allow(unused_variables)]
 
 use std::str;
 
-named_args!(atom<'a>(tomb: &'a mut ())<String>,
-            map!(map_res!(is_not!(" \t\r\n()"), str::from_utf8), ToString::to_string));
+use nom::bytes::complete::is_not;
+use nom::character::complete::char;
+use nom::combinator::{map, map_res};
+use nom::multi::fold_many0;
+use nom::sequence::delimited;
+use nom::IResult;
+
+fn atom<'a>(_tomb: &'a mut ()) -> impl FnMut(&'a [u8]) -> IResult<&'a [u8], String> {
+  move |input| {
+    map(
+      map_res(is_not(" \t\r\n"), str::from_utf8),
+      ToString::to_string,
+    )(input)
+  }
+}
 
-/*FIXME: should we support the use case of borrowing data mutably in a parser?
-named_args!(list<'a>(tomb: &'a mut ())<String>,
-  delimited!(
-    char!('('),
-    fold_many0!(call!(atom, tomb), "".to_string(), |acc: String, next: String| acc + next.as_str()),
-    char!(')')));
-*/
+// FIXME: should we support the use case of borrowing data mutably in a parser?
+fn list<'a>(i: &'a [u8], tomb: &'a mut ()) -> IResult<&'a [u8], String> {
+  delimited(
+    char('('),
+    fold_many0(atom(tomb), String::new(), |acc: String, next: String| {
+      acc + next.as_str()
+    }),
+    char(')'),
+  )(i)
+}