From 7cc54e08c74d8c88cf16f39aef601567e3d19d85 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Wed, 18 Nov 2015 18:00:50 +0100 Subject: [PATCH] Forgot to include static analysis comprehension tests a while ago. --- test/static_analysis/comprehensions.py | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 test/static_analysis/comprehensions.py diff --git a/test/static_analysis/comprehensions.py b/test/static_analysis/comprehensions.py new file mode 100644 index 00000000..36c60e37 --- /dev/null +++ b/test/static_analysis/comprehensions.py @@ -0,0 +1,30 @@ +[a + 1 for a in [1, 2]] + +#! 3 type-error-operation +[a + '' for a in [1, 2]] +#! 3 type-error-operation +(a + '' for a in [1, 2]) + +#! 12 type-error-not-iterable +[a for a in 1] + +tuple(str(a) for a in [1]) + +#! 8 type-error-operation +tuple(a + 3 for a in ['']) + +# ---------- +# Some variables within are not defined +# ---------- + +#! 12 name-error +[1 for a in NOT_DEFINFED for b in a if 1] + +#! 25 name-error +[1 for a in [1] for b in NOT_DEFINED if 1] + +#! 12 name-error +[1 for a in NOT_DEFINFED for b in [1] if 1] + +#! 19 name-error +(1 for a in [1] if NOT_DEFINED)