Skip to content
This repository has been archived by the owner on Jun 10, 2024. It is now read-only.

Commit

Permalink
Integration tests for convert_time_unit/3 including badarg
Browse files Browse the repository at this point in the history
  • Loading branch information
KronicDeth committed Sep 29, 2020
1 parent 172bcee commit d2695e3
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 134 deletions.
3 changes: 0 additions & 3 deletions native_implemented/otp/src/erlang/convert_time_unit_3.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#[cfg(all(not(target_arch = "wasm32"), test))]
mod test;

use std::convert::TryInto;

use anyhow::*;
Expand Down
118 changes: 0 additions & 118 deletions native_implemented/otp/src/erlang/convert_time_unit_3/test.rs

This file was deleted.

10 changes: 0 additions & 10 deletions native_implemented/otp/src/macros/exception.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,16 +223,6 @@ macro_rules! prop_assert_is_not_number {
};
}

#[cfg(test)]
macro_rules! prop_assert_is_not_time_unit {
($actual:expr, $name:ident) => {
prop_assert_is_not_time_unit!($actual, stringify!($name), $name)
};
($actual:expr, $name:expr, $value:expr) => {
prop_assert_is_not_type!($actual, $name, $value, "a time unit")
};
}

#[cfg(test)]
macro_rules! prop_assert_is_not_tuple {
($actual:expr, $name:ident) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// `without_integer_time_returns_badarg` in unit tests
// `with_integer_time_without_unit_from_unit_errors_badarg` in unit tests
// `with_integer_time_with_unit_from_unit_without_unit_to_unit_errors_badarg` in unit tests
test_stdout!(without_integer_time_returns_badarg, "{caught, error, badarg}\n{caught, error, badarg}\n{caught, error, badarg}\n{caught, error, badarg}\n{caught, error, badarg}\n{caught, error, badarg}\n{caught, error, badarg}\n{caught, error, badarg}\n{caught, error, badarg}\n{caught, error, badarg}\n");
test_stdout!(with_integer_time_without_unit_from_unit_errors_badarg, "{caught, error, badarg}\n{caught, error, badarg}\n{caught, error, badarg}\n{caught, error, badarg}\n{caught, error, badarg}\n{caught, error, badarg}\n{caught, error, badarg}\n{caught, error, badarg}\n{caught, error, badarg}\n");
test_stdout!(with_integer_time_with_unit_from_unit_without_unit_to_unit_errors_badarg, "{caught, error, badarg}\n{caught, error, badarg}\n{caught, error, badarg}\n{caught, error, badarg}\n{caught, error, badarg}\n{caught, error, badarg}\n{caught, error, badarg}\n{caught, error, badarg}\n{caught, error, badarg}\n");
test_stdout!(with_small_integer_time_valid_units_returns_converted_value, "true\n2000000000\n500000000\n500000000000\n500000000000000000\n500000000000\n500000000000\n5000000000\n1000000000\n1000000000000\n1000000000000000000\n1000000000000\n1000000000000\n5000000\n1000000\n1000000000\n1000000000000000\n1000000000\n1000000000\n5000\n1000\n1000000\n1000000000000\n1000000\n1000000\n5\n1\n1000\n1000000000\n1000\n1000\n5000000\n1000000\n1000000000\n1000000000000000\n1000000000\n1000000000\n5000000\n1000000\n1000000000\n1000000000000000\n1000000000\n1000000000\n");
test_stdout!(with_big_integer_time_with_unit_from_unit_with_unit_to_unit_returns_converted_value, "true\n2000000000000000000\n500000000000000000\n500000000000000000000\n500000000000000000000000000\n500000000000000000000\n500000000000000000000\n5000000000000000000\n1000000000000000000\n1000000000000000000000\n1000000000000000000000000000\n1000000000000000000000\n1000000000000000000000\n5000000000000000\n1000000000000000\n1000000000000000000\n1000000000000000000000000\n1000000000000000000\n1000000000000000000\n5000000000000\n1000000000000\n1000000000000000\n1000000000000000000000\n1000000000000000\n1000000000000000\n5000000000\n1000000000\n1000000000000\n1000000000000000000\n1000000000000\n1000000000000\n5000000000000000\n1000000000000000\n1000000000000000000\n1000000000000000000000000\n1000000000000000000\n1000000000000000000\n5000000000000000\n1000000000000000\n1000000000000000000\n1000000000000000000000000\n1000000000000000000\n1000000000000000000\n");
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-module(init).
-export([start/0]).
-import(erlang, [convert_time_unit/3]).

start() ->
test:each(fun
(Integer) when is_integer(Integer) -> ignore;
(Atom) when is_atom(Atom) -> ignore;
(Term) -> test(Term)
end).

test(ToUnit) ->
test:caught(fun () ->
convert_time_unit(0, native, ToUnit)
end).
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-module(init).
-export([start/0]).
-import(erlang, [convert_time_unit/3]).

start() ->
test:each(fun
(Integer) when is_integer(Integer) -> ignore;
(Atom) when is_atom(Atom) -> ignore;
(Term) -> test(Term)
end).

test(FromUnit) ->
test:caught(fun () ->
convert_time_unit(0, FromUnit, native)
end).
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-module(init).
-export([start/0]).
-import(erlang, [convert_time_unit/3]).

start() ->
test:each(fun
(Integer) when is_integer(Integer) -> ignore;
(Term) -> test(Term)
end).

test(Time) ->
test:caught(fun () ->
convert_time_unit(Time, native, native)
end).

0 comments on commit d2695e3

Please sign in to comment.