diff options
author | Patrik Nyblom <pan@erlang.org> | 2010-04-22 18:45:36 +0200 |
---|---|---|
committer | Björn Gustavsson <bjorn@erlang.org> | 2010-05-17 15:51:50 +0200 |
commit | a6c89679cd6006b3e9839b426159fd4302321528 (patch) | |
tree | d4130f60a617aad3697b6492dc5d224bf4e42fdd /lib/stdlib/test/binref.erl | |
parent | 8e8e10d9d080655edba6dedbc13d9e729f209e2e (diff) | |
download | otp-a6c89679cd6006b3e9839b426159fd4302321528.tar.gz otp-a6c89679cd6006b3e9839b426159fd4302321528.tar.bz2 otp-a6c89679cd6006b3e9839b426159fd4302321528.zip |
Add binary:part to erl_bif_binary.c
Change name of the 'scope' option for binary:match/matches.
Add split and replace to binary.erl.
Cleanup comments etc in binary.erl and atom.names
Add testcases for part, split, replace and scopes.
Diffstat (limited to 'lib/stdlib/test/binref.erl')
-rw-r--r-- | lib/stdlib/test/binref.erl | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/stdlib/test/binref.erl b/lib/stdlib/test/binref.erl index d93f82fda9..484112428c 100644 --- a/lib/stdlib/test/binref.erl +++ b/lib/stdlib/test/binref.erl @@ -143,8 +143,16 @@ split(H,N) -> split(H,N,[]). split(Haystack,{Needles},Options) -> split(Haystack, Needles, Options); -split(Haystack,Needles,Options) -> +split(Haystack,Needles0,Options) -> try + Needles = if + is_list(Needles0) -> + Needles0; + is_binary(Needles0) -> + [Needles0]; + true -> + exit(badtype) + end, {Part,Global,Trim} = get_opts_split(Options,{nomatch,false,false}), {Start,End,NewStack} = case Part of @@ -203,8 +211,16 @@ replace(H,N,R) -> replace(Haystack,{Needles},Replacement,Options) -> replace(Haystack,Needles,Replacement,Options); -replace(Haystack,Needles,Replacement,Options) -> +replace(Haystack,Needles0,Replacement,Options) -> try + Needles = if + is_list(Needles0) -> + Needles0; + is_binary(Needles0) -> + [Needles0]; + true -> + exit(badtype) + end, true = is_binary(Replacement), % Make badarg instead of function clause {Part,Global,Insert} = get_opts_replace(Options,{nomatch,false,[]}), {Start,End,NewStack} = |