aboutsummaryrefslogtreecommitdiffstats
path: root/lib/syntax_tools/examples/test_comprehensions.erl
diff options
context:
space:
mode:
authorErlang/OTP <[email protected]>2009-11-20 14:54:40 +0000
committerErlang/OTP <[email protected]>2009-11-20 14:54:40 +0000
commit84adefa331c4159d432d22840663c38f155cd4c1 (patch)
treebff9a9c66adda4df2106dfd0e5c053ab182a12bd /lib/syntax_tools/examples/test_comprehensions.erl
downloadotp-84adefa331c4159d432d22840663c38f155cd4c1.tar.gz
otp-84adefa331c4159d432d22840663c38f155cd4c1.tar.bz2
otp-84adefa331c4159d432d22840663c38f155cd4c1.zip
The R13B03 release.OTP_R13B03
Diffstat (limited to 'lib/syntax_tools/examples/test_comprehensions.erl')
-rw-r--r--lib/syntax_tools/examples/test_comprehensions.erl39
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/syntax_tools/examples/test_comprehensions.erl b/lib/syntax_tools/examples/test_comprehensions.erl
new file mode 100644
index 0000000000..ede9caeaed
--- /dev/null
+++ b/lib/syntax_tools/examples/test_comprehensions.erl
@@ -0,0 +1,39 @@
+%%%-------------------------------------------------------------------
+%%% File : test_comprehensions.erl
+%%% Author : Per Gustafsson <pergu@jobberl>
+%%% Description : Test module to see that pretty printing etc.
+%%% works on extended comprehensions
+%%% Created : 15 Oct 2007 by Per Gustafsson <pergu@jobberl>
+%%%-------------------------------------------------------------------
+-module(test_comprehensions).
+
+-compile(binary_comprehension).
+
+-export([test/0]).
+
+test() ->
+ {bbc(),llc(),blc(),lbc(),bblc(),lblc()}.
+
+binary() ->
+ <<1,2,3>>.
+
+list() ->
+ [1,2,3].
+
+bbc() ->
+ << <<X>> || <<X>> <= binary(), X > 1 >>.
+
+llc() ->
+ [X || X <- list(), X > 1].
+
+blc() ->
+ << <<X>> || X <- list(), X > 1 >>.
+
+lbc() ->
+ [X || <<X>> <= binary(), X > 1].
+
+bblc() ->
+ << <<(X+Y)>> || <<X>> <= binary(), Y <- list(), X > 1 >>.
+
+lblc() ->
+ [(X+Y) || <<X>> <= binary(), Y <- list(), X > 1].