gems.sass-3.2.9.test.sass.script_conversion_test.rb Maven / Gradle / Ivy
Go to download
Sass makes CSS fun again. Sass is an extension of CSS3, adding nested rules, variables, mixins, selector
inheritance, and more. It's translated to well-formatted, standard CSS using the command line tool or a
web-framework plugin.
This is a repackaged GEM in a JAR format of the sass-lang.gem package. The sass-gems package version
follows the sass-lang.gem versions located http://rubyforge.org/frs/?group_id=9702. Simply change
the version of this package to download and repackage the same GEM version.
The newest version!
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require File.dirname(__FILE__) + '/../test_helper'
require 'sass/engine'
class SassScriptConversionTest < Test::Unit::TestCase
def test_bool
assert_renders "true"
assert_renders "false"
end
def test_color
assert_renders "#abcdef"
assert_renders "blue"
assert_renders "rgba(0, 1, 2, 0.2)"
assert_equal "#aabbcc", render("#abc")
assert_equal "blue", render("#0000ff")
end
def test_number
assert_renders "10"
assert_renders "10.35"
assert_renders "12px"
assert_renders "12.45px"
assert_equal "12.34568", render("12.345678901")
end
def test_string
assert_renders '"foo"'
assert_renders '"bar baz"'
assert_equal '"baz bang"', render("'baz bang'")
end
def test_string_quotes
assert_equal "'quote\"quote'", render('"quote\\"quote"')
assert_equal '"quote\'quote"', render("'quote\\'quote'")
assert_renders '"quote\'quote\\"quote"'
assert_equal '"quote\'quote\\"quote"', render("'quote\\'quote\"quote'")
end
def test_string_escapes
assert_renders '"foo\\\\bar"'
end
def test_funcall
assert_renders "foo(true, blue)"
assert_renders "hsla(20deg, 30%, 50%, 0.3)"
assert_renders "blam()"
assert_renders "-\xC3\xBFoo(12px)"
assert_renders "-foo(12px)"
end
def test_funcall_with_keyword_args
assert_renders "foo(arg1, arg2, $karg1: val, $karg2: val2)"
assert_renders "foo($karg1: val, $karg2: val2)"
end
def test_url
assert_renders "url(foo.gif)"
assert_renders "url($var)"
assert_renders "url(\#{$var}/flip.gif)"
end
def test_variable
assert_renders "$foo-bar"
assert_renders "$flaznicate"
end
def test_null
assert_renders "null"
end
def test_empty_list
assert_renders "()"
end
def test_list_in_args
assert_renders "foo((a, b, c))"
assert_renders "foo($arg: (a, b, c))"
assert_renders "foo(a, b, (a, b, c)...)"
end
def self.test_precedence(outer, inner)
op_outer = Sass::Script::Lexer::OPERATORS_REVERSE[outer]
op_inner = Sass::Script::Lexer::OPERATORS_REVERSE[inner]
class_eval <