diff options
author | Kostis Sagonas <[email protected]> | 2014-03-03 01:40:39 +0100 |
---|---|---|
committer | Kostis Sagonas <[email protected]> | 2015-12-16 22:08:32 +0100 |
commit | 9fd2f21c38944c8a605020d6662bb5935c5bbee2 (patch) | |
tree | 8f2dd4a13315d93e54eae79b2e1645fc439c1d58 /lib/hipe/test/basic_SUITE_data/basic_pattern_match.erl | |
parent | 82a835d94be7ee5e98d101a29999fedaf6cd75fe (diff) | |
download | otp-9fd2f21c38944c8a605020d6662bb5935c5bbee2.tar.gz otp-9fd2f21c38944c8a605020d6662bb5935c5bbee2.tar.bz2 otp-9fd2f21c38944c8a605020d6662bb5935c5bbee2.zip |
First part of the basic test suite for the HiPE compiler
Diffstat (limited to 'lib/hipe/test/basic_SUITE_data/basic_pattern_match.erl')
-rw-r--r-- | lib/hipe/test/basic_SUITE_data/basic_pattern_match.erl | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/hipe/test/basic_SUITE_data/basic_pattern_match.erl b/lib/hipe/test/basic_SUITE_data/basic_pattern_match.erl new file mode 100644 index 0000000000..9922b34415 --- /dev/null +++ b/lib/hipe/test/basic_SUITE_data/basic_pattern_match.erl @@ -0,0 +1,36 @@ +%%% -*- erlang-indent-level: 2 -*- +%%%------------------------------------------------------------------- +%%% Author: Kostis Sagonas +%%% +%%% Contains code examples that test pattern matching against terms of +%%% various types. +%%%------------------------------------------------------------------- +-module(basic_pattern_match). + +-export([test/0]). + +test() -> + ok = test_hello_world(), + ok. + +%%-------------------------------------------------------------------- +%% Trivial test to test pattern matching compilation with atoms, the +%% correct handling of all sorts of alphanumeric types in Erlang, and +%% conversions between them. + +test_hello_world() -> + String = gimme(string), + String = atom_to_list(gimme(atom)), + String = binary_to_list(gimme(binary)), + true = (list_to_atom(String) =:= gimme(atom)), + true = (list_to_binary(String) =:= gimme(binary)), + ok. + +gimme(string) -> + "hello world"; +gimme(atom) -> + 'hello world'; +gimme(binary) -> + <<"hello world">>. + +%%-------------------------------------------------------------------- |