aboutsummaryrefslogtreecommitdiffstats
path: root/lib/syntax_tools/examples/test_comprehensions.erl
diff options
context:
space:
mode:
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].