summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEevee <eevee.git@veekun.com>2013-06-28 14:41:24 -0700
committerEevee <eevee.git@veekun.com>2013-06-28 14:41:24 -0700
commit10f365c1d643f9dfc1ad59c2720557aa68f08374 (patch)
treea0dd2e1f837294c76218600559789084cc05367a
parent324610ac06f8bd0c9c81b97331c6d80c312c4eb2 (diff)
downloadpyscss-10f365c1d643f9dfc1ad59c2720557aa68f08374.tar.gz
Couple more compass helper tests.
-rw-r--r--scss/functions/compass/helpers.py20
-rw-r--r--scss/tests/functions/compass/test_helpers.py8
-rw-r--r--scss/types.py6
3 files changed, 21 insertions, 13 deletions
diff --git a/scss/functions/compass/helpers.py b/scss/functions/compass/helpers.py
index 8c9a91f..bfe4a7e 100644
--- a/scss/functions/compass/helpers.py
+++ b/scss/functions/compass/helpers.py
@@ -16,7 +16,7 @@ import time
from scss import config
from scss.functions.library import FunctionLibrary
-from scss.types import BooleanValue, ListValue, NumberValue, QuotedStringValue, StringValue
+from scss.types import BooleanValue, ListValue, NullValue, NumberValue, QuotedStringValue, StringValue
from scss.util import escape, to_str
log = logging.getLogger(__name__)
@@ -87,7 +87,7 @@ def reject(lst, *values):
if isinstance(values, ListValue):
values = values.value.values()
elif not isinstance(values, (list, tuple)):
- values = list(values)
+ values = ListValue([values])
for i, item in lst.items():
if item not in values:
ret[i] = item
@@ -98,11 +98,17 @@ def reject(lst, *values):
@register('first-value-of')
-def first_value_of(*lst):
- if len(lst) == 1 and isinstance(lst[0], (list, tuple, ListValue)):
- lst = ListValue(lst[0])
- ret = ListValue(lst).first()
- return ret.__class__(ret)
+def first_value_of(lst):
+ if isinstance(lst, QuotedStringValue):
+ first = lst.value.split()[0]
+ return type(lst)(first)
+ elif isinstance(lst, ListValue):
+ if len(lst):
+ return lst[0]
+ else:
+ return NullValue()
+ else:
+ return lst
@register('-compass-list')
diff --git a/scss/tests/functions/compass/test_helpers.py b/scss/tests/functions/compass/test_helpers.py
index 07a7b5c..8cdca99 100644
--- a/scss/tests/functions/compass/test_helpers.py
+++ b/scss/tests/functions/compass/test_helpers.py
@@ -43,3 +43,11 @@ def test_blank(calc):
def test_compact(calc):
assert calc('compact(1 2 3 false 4 5 null 6 7)') == calc('1 2 3 4 5 6 7')
+
+def test_reject(calc):
+ assert calc('reject(a b c d, a, c)') == calc('b d')
+ assert calc('reject(a b c d, e)') == calc('a b c d')
+
+def test_first_value_of(calc):
+ assert calc('first-value-of(a b c d)') == calc('a')
+ assert calc('first-value-of("a b c d")') == calc('"a"')
diff --git a/scss/types.py b/scss/types.py
index b56f600..5ba919f 100644
--- a/scss/types.py
+++ b/scss/types.py
@@ -417,12 +417,6 @@ class ListValue(Value):
def items(self):
return sorted((k, v) for k, v in self.value.items() if k != '_')
- def first(self):
- for v in self.values():
- if bool(v):
- return v
- return v
-
def __getitem__(self, key):
return self.value[key]