sass 3.3.0.alpha.149 → 3.3.0.alpha.162

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. data/REVISION +1 -1
  2. data/VERSION +1 -1
  3. data/VERSION_DATE +1 -1
  4. data/lib/sass/css.rb +1 -1
  5. data/lib/sass/engine.rb +4 -4
  6. data/lib/sass/environment.rb +1 -1
  7. data/lib/sass/exec.rb +1 -1
  8. data/lib/sass/media.rb +15 -15
  9. data/lib/sass/script.rb +32 -7
  10. data/lib/sass/script/css_lexer.rb +2 -2
  11. data/lib/sass/script/css_parser.rb +1 -1
  12. data/lib/sass/script/functions.rb +246 -232
  13. data/lib/sass/script/lexer.rb +24 -32
  14. data/lib/sass/script/parser.rb +84 -65
  15. data/lib/sass/script/tree.rb +14 -0
  16. data/lib/sass/script/tree/funcall.rb +242 -0
  17. data/lib/sass/script/{interpolation.rb → tree/interpolation.rb} +30 -13
  18. data/lib/sass/script/tree/list_literal.rb +65 -0
  19. data/lib/sass/script/tree/literal.rb +46 -0
  20. data/lib/sass/script/{node.rb → tree/node.rb} +10 -10
  21. data/lib/sass/script/{operation.rb → tree/operation.rb} +16 -27
  22. data/lib/sass/script/{string_interpolation.rb → tree/string_interpolation.rb} +4 -4
  23. data/lib/sass/script/{unary_operation.rb → tree/unary_operation.rb} +7 -8
  24. data/lib/sass/script/tree/variable.rb +56 -0
  25. data/lib/sass/script/value.rb +10 -0
  26. data/lib/sass/script/{arg_list.rb → value/arg_list.rb} +5 -20
  27. data/lib/sass/script/value/base.rb +222 -0
  28. data/lib/sass/script/{bool.rb → value/bool.rb} +2 -2
  29. data/lib/sass/script/{color.rb → value/color.rb} +22 -20
  30. data/lib/sass/script/{list.rb → value/list.rb} +15 -28
  31. data/lib/sass/script/{null.rb → value/null.rb} +3 -3
  32. data/lib/sass/script/{number.rb → value/number.rb} +19 -19
  33. data/lib/sass/script/{string.rb → value/string.rb} +7 -7
  34. data/lib/sass/scss/parser.rb +14 -4
  35. data/lib/sass/selector.rb +26 -26
  36. data/lib/sass/selector/abstract_sequence.rb +1 -1
  37. data/lib/sass/selector/simple.rb +6 -7
  38. data/lib/sass/source/position.rb +13 -0
  39. data/lib/sass/supports.rb +4 -4
  40. data/lib/sass/tree/comment_node.rb +3 -3
  41. data/lib/sass/tree/css_import_node.rb +7 -7
  42. data/lib/sass/tree/debug_node.rb +2 -2
  43. data/lib/sass/tree/directive_node.rb +2 -2
  44. data/lib/sass/tree/each_node.rb +2 -2
  45. data/lib/sass/tree/extend_node.rb +4 -4
  46. data/lib/sass/tree/for_node.rb +4 -4
  47. data/lib/sass/tree/function_node.rb +4 -4
  48. data/lib/sass/tree/media_node.rb +3 -3
  49. data/lib/sass/tree/mixin_def_node.rb +4 -4
  50. data/lib/sass/tree/mixin_node.rb +6 -6
  51. data/lib/sass/tree/prop_node.rb +23 -15
  52. data/lib/sass/tree/return_node.rb +2 -2
  53. data/lib/sass/tree/rule_node.rb +3 -3
  54. data/lib/sass/tree/variable_node.rb +2 -2
  55. data/lib/sass/tree/visitors/convert.rb +2 -2
  56. data/lib/sass/tree/visitors/deep_copy.rb +5 -5
  57. data/lib/sass/tree/visitors/perform.rb +7 -7
  58. data/lib/sass/tree/visitors/set_options.rb +6 -6
  59. data/lib/sass/tree/visitors/to_css.rb +1 -1
  60. data/lib/sass/tree/warn_node.rb +2 -2
  61. data/lib/sass/tree/while_node.rb +2 -2
  62. data/lib/sass/util.rb +2 -2
  63. data/test/sass/engine_test.rb +6 -6
  64. data/test/sass/functions_test.rb +20 -20
  65. data/test/sass/plugin_test.rb +2 -2
  66. data/test/sass/script_test.rb +38 -29
  67. data/test/test_helper.rb +1 -1
  68. metadata +23 -19
  69. data/lib/sass/script/funcall.rb +0 -238
  70. data/lib/sass/script/literal.rb +0 -221
  71. data/lib/sass/script/variable.rb +0 -58
@@ -9,11 +9,11 @@ module Sass::Tree
9
9
  PARENT = '&'
10
10
 
11
11
  # The CSS selector for this rule,
12
- # interspersed with {Sass::Script::Node}s
12
+ # interspersed with {Sass::Script::Tree::Node}s
13
13
  # representing `#{}`-interpolation.
14
14
  # Any adjacent strings will be merged together.
15
15
  #
16
- # @return [Array<String, Sass::Script::Node>]
16
+ # @return [Array<String, Sass::Script::Tree::Node>]
17
17
  attr_accessor :rule
18
18
 
19
19
  # The CSS selector for this rule,
@@ -60,7 +60,7 @@ module Sass::Tree
60
60
  # @return [Array<String>]
61
61
  attr_accessor :stack_trace
62
62
 
63
- # @param rule [Array<String, Sass::Script::Node>]
63
+ # @param rule [Array<String, Sass::Script::Tree::Node>]
64
64
  # @param selector_source_range [Sass::Source::Range]
65
65
  # The CSS rule. See \{#rule}
66
66
  def initialize(rule, selector_source_range = nil)
@@ -9,7 +9,7 @@ module Sass
9
9
  attr_reader :name
10
10
 
11
11
  # The parse tree for the variable value.
12
- # @return [Script::Node]
12
+ # @return [Script::Tree::Node]
13
13
  attr_accessor :expr
14
14
 
15
15
  # Whether this is a guarded variable assignment (`!default`).
@@ -17,7 +17,7 @@ module Sass
17
17
  attr_reader :guarded
18
18
 
19
19
  # @param name [String] The name of the variable
20
- # @param expr [Script::Node] See \{#expr}
20
+ # @param expr [Script::Tree::Node] See \{#expr}
21
21
  # @param guarded [Boolean] See \{#guarded}
22
22
  def initialize(name, expr, guarded)
23
23
  @name = name
@@ -160,7 +160,7 @@ class Sass::Tree::Visitors::Convert < Sass::Tree::Visitors::Base
160
160
  end
161
161
 
162
162
  def visit_cssimport(node)
163
- if node.uri.is_a?(Sass::Script::Node)
163
+ if node.uri.is_a?(Sass::Script::Tree::Node)
164
164
  str = "#{tab_str}@import #{node.uri.to_sass(@options)}"
165
165
  else
166
166
  str = "#{tab_str}@import #{node.uri}"
@@ -197,7 +197,7 @@ class Sass::Tree::Visitors::Convert < Sass::Tree::Visitors::Base
197
197
  def visit_mixin(node)
198
198
  arg_to_sass = lambda do |arg|
199
199
  sass = arg.to_sass(@options)
200
- sass = "(#{sass})" if arg.is_a?(Sass::Script::List) && arg.separator == :comma
200
+ sass = "(#{sass})" if arg.is_a?(Sass::Script::Tree::ListLiteral) && arg.separator == :comma
201
201
  sass
202
202
  end
203
203
 
@@ -22,7 +22,7 @@ class Sass::Tree::Visitors::DeepCopy < Sass::Tree::Visitors::Base
22
22
  end
23
23
 
24
24
  def visit_extend(node)
25
- node.selector = node.selector.map {|c| c.is_a?(Sass::Script::Node) ? c.deep_copy : c}
25
+ node.selector = node.selector.map {|c| c.is_a?(Sass::Script::Tree::Node) ? c.deep_copy : c}
26
26
  yield
27
27
  end
28
28
 
@@ -55,7 +55,7 @@ class Sass::Tree::Visitors::DeepCopy < Sass::Tree::Visitors::Base
55
55
  end
56
56
 
57
57
  def visit_prop(node)
58
- node.name = node.name.map {|c| c.is_a?(Sass::Script::Node) ? c.deep_copy : c}
58
+ node.name = node.name.map {|c| c.is_a?(Sass::Script::Tree::Node) ? c.deep_copy : c}
59
59
  node.value = node.value.deep_copy
60
60
  yield
61
61
  end
@@ -66,7 +66,7 @@ class Sass::Tree::Visitors::DeepCopy < Sass::Tree::Visitors::Base
66
66
  end
67
67
 
68
68
  def visit_rule(node)
69
- node.rule = node.rule.map {|c| c.is_a?(Sass::Script::Node) ? c.deep_copy : c}
69
+ node.rule = node.rule.map {|c| c.is_a?(Sass::Script::Tree::Node) ? c.deep_copy : c}
70
70
  yield
71
71
  end
72
72
 
@@ -86,12 +86,12 @@ class Sass::Tree::Visitors::DeepCopy < Sass::Tree::Visitors::Base
86
86
  end
87
87
 
88
88
  def visit_directive(node)
89
- node.value = node.value.map {|c| c.is_a?(Sass::Script::Node) ? c.deep_copy : c}
89
+ node.value = node.value.map {|c| c.is_a?(Sass::Script::Tree::Node) ? c.deep_copy : c}
90
90
  yield
91
91
  end
92
92
 
93
93
  def visit_media(node)
94
- node.query = node.query.map {|c| c.is_a?(Sass::Script::Node) ? c.deep_copy : c}
94
+ node.query = node.query.map {|c| c.is_a?(Sass::Script::Tree::Node) ? c.deep_copy : c}
95
95
  yield
96
96
  end
97
97
 
@@ -41,10 +41,10 @@ class Sass::Tree::Visitors::Perform < Sass::Tree::Visitors::Base
41
41
  splat_sep = :comma
42
42
  if splat
43
43
  args += splat.to_a
44
- splat_sep = splat.separator if splat.is_a?(Sass::Script::List)
44
+ splat_sep = splat.separator if splat.is_a?(Sass::Script::Value::List)
45
45
  # If the splat argument exists, there won't be any keywords passed in
46
46
  # manually, so we can safely overwrite rather than merge here.
47
- keywords = splat.keywords if splat.is_a?(Sass::Script::ArgList)
47
+ keywords = splat.keywords if splat.is_a?(Sass::Script::Value::ArgList)
48
48
  end
49
49
 
50
50
  keywords = keywords.dup
@@ -62,7 +62,7 @@ class Sass::Tree::Visitors::Perform < Sass::Tree::Visitors::Base
62
62
 
63
63
  if callable.splat
64
64
  rest = args[callable.args.length..-1]
65
- arg_list = Sass::Script::ArgList.new(rest, keywords.dup, splat_sep)
65
+ arg_list = Sass::Script::Value::ArgList.new(rest, keywords.dup, splat_sep)
66
66
  arg_list.options = env.options
67
67
  env.set_local_var(callable.splat.name, arg_list)
68
68
  end
@@ -142,7 +142,7 @@ class Sass::Tree::Visitors::Perform < Sass::Tree::Visitors::Base
142
142
  # Prints the expression to STDERR.
143
143
  def visit_debug(node)
144
144
  res = node.expr.perform(@environment)
145
- res = res.value if res.is_a?(Sass::Script::String)
145
+ res = res.value if res.is_a?(Sass::Script::Value::String)
146
146
  if node.filename
147
147
  $stderr.puts "#{node.filename}:#{node.line} DEBUG: #{res}"
148
148
  else
@@ -185,7 +185,7 @@ class Sass::Tree::Visitors::Perform < Sass::Tree::Visitors::Base
185
185
  with_environment Sass::Environment.new(@environment) do
186
186
  range.map do |i|
187
187
  @environment.set_local_var(node.var,
188
- Sass::Script::Number.new(i, from.numerator_units, from.denominator_units))
188
+ Sass::Script::Value::Number.new(i, from.numerator_units, from.denominator_units))
189
189
  node.children.map {|c| visit(c)}
190
190
  end.flatten
191
191
  end
@@ -343,7 +343,7 @@ class Sass::Tree::Visitors::Perform < Sass::Tree::Visitors::Base
343
343
  def visit_warn(node)
344
344
  @stack.push(:filename => node.filename, :line => node.line)
345
345
  res = node.expr.perform(@environment)
346
- res = res.value if res.is_a?(Sass::Script::String)
346
+ res = res.value if res.is_a?(Sass::Script::Value::String)
347
347
  msg = "WARNING: #{res}\n "
348
348
  msg << stack_trace.join("\n ") << "\n"
349
349
  Sass::Util.sass_warn msg
@@ -409,7 +409,7 @@ class Sass::Tree::Visitors::Perform < Sass::Tree::Visitors::Base
409
409
  next r if r.is_a?(String)
410
410
  val = r.perform(@environment)
411
411
  # Interpolated strings should never render with quotes
412
- next val.value if val.is_a?(Sass::Script::String)
412
+ next val.value if val.is_a?(Sass::Script::Value::String)
413
413
  val.to_s
414
414
  end.join
415
415
  end
@@ -26,7 +26,7 @@ class Sass::Tree::Visitors::SetOptions < Sass::Tree::Visitors::Base
26
26
  end
27
27
 
28
28
  def visit_extend(node)
29
- node.selector.each {|c| c.options = @options if c.is_a?(Sass::Script::Node)}
29
+ node.selector.each {|c| c.options = @options if c.is_a?(Sass::Script::Tree::Node)}
30
30
  yield
31
31
  end
32
32
 
@@ -73,7 +73,7 @@ class Sass::Tree::Visitors::SetOptions < Sass::Tree::Visitors::Base
73
73
  end
74
74
 
75
75
  def visit_prop(node)
76
- node.name.each {|c| c.options = @options if c.is_a?(Sass::Script::Node)}
76
+ node.name.each {|c| c.options = @options if c.is_a?(Sass::Script::Tree::Node)}
77
77
  node.value.options = @options
78
78
  yield
79
79
  end
@@ -84,7 +84,7 @@ class Sass::Tree::Visitors::SetOptions < Sass::Tree::Visitors::Base
84
84
  end
85
85
 
86
86
  def visit_rule(node)
87
- node.rule.each {|c| c.options = @options if c.is_a?(Sass::Script::Node)}
87
+ node.rule.each {|c| c.options = @options if c.is_a?(Sass::Script::Tree::Node)}
88
88
  yield
89
89
  end
90
90
 
@@ -104,17 +104,17 @@ class Sass::Tree::Visitors::SetOptions < Sass::Tree::Visitors::Base
104
104
  end
105
105
 
106
106
  def visit_directive(node)
107
- node.value.each {|c| c.options = @options if c.is_a?(Sass::Script::Node)}
107
+ node.value.each {|c| c.options = @options if c.is_a?(Sass::Script::Tree::Node)}
108
108
  yield
109
109
  end
110
110
 
111
111
  def visit_media(node)
112
- node.query.each {|c| c.options = @options if c.is_a?(Sass::Script::Node)}
112
+ node.query.each {|c| c.options = @options if c.is_a?(Sass::Script::Tree::Node)}
113
113
  yield
114
114
  end
115
115
 
116
116
  def visit_cssimport(node)
117
- node.query.each {|c| c.options = @options if c.is_a?(Sass::Script::Node)} if node.query
117
+ node.query.each {|c| c.options = @options if c.is_a?(Sass::Script::Tree::Node)} if node.query
118
118
  yield
119
119
  end
120
120
 
@@ -343,7 +343,7 @@ class Sass::Tree::Visitors::ToCss < Sass::Tree::Visitors::Base
343
343
  false)
344
344
  ])
345
345
  ])
346
- prop = Sass::Tree::PropNode.new([""], Sass::Script::String.new(''), :new)
346
+ prop = Sass::Tree::PropNode.new([""], Sass::Script::Value::String.new(''), :new)
347
347
  prop.resolved_name = "font-family"
348
348
  prop.resolved_value = Sass::SCSS::RX.escape_ident(v.to_s)
349
349
  rule << prop
@@ -5,10 +5,10 @@ module Sass
5
5
  # @see Sass::Tree
6
6
  class WarnNode < Node
7
7
  # The expression to print.
8
- # @return [Script::Node]
8
+ # @return [Script::Tree::Node]
9
9
  attr_accessor :expr
10
10
 
11
- # @param expr [Script::Node] The expression to print
11
+ # @param expr [Script::Tree::Node] The expression to print
12
12
  def initialize(expr)
13
13
  @expr = expr
14
14
  super()
@@ -6,10 +6,10 @@ module Sass::Tree
6
6
  # @see Sass::Tree
7
7
  class WhileNode < Node
8
8
  # The parse tree for the continuation expression.
9
- # @return [Script::Node]
9
+ # @return [Script::Tree::Node]
10
10
  attr_accessor :expr
11
11
 
12
- # @param expr [Script::Node] See \{#expr}
12
+ # @param expr [Script::Tree::Node] See \{#expr}
13
13
  def initialize(expr)
14
14
  @expr = expr
15
15
  super()
@@ -289,14 +289,14 @@ module Sass
289
289
  #
290
290
  # @param name [String] The name of the value. Used in the error message.
291
291
  # @param range [Range] The allowed range of values.
292
- # @param value [Numeric, Sass::Script::Number] The value to check.
292
+ # @param value [Numeric, Sass::Script::Value::Number] The value to check.
293
293
  # @param unit [String] The unit of the value. Used in error reporting.
294
294
  # @return [Numeric] `value` adjusted to fall within range, if it
295
295
  # was outside by a floating-point margin.
296
296
  def check_range(name, range, value, unit='')
297
297
  grace = (-0.00001..0.00001)
298
298
  str = value.to_s
299
- value = value.value if value.is_a?(Sass::Script::Number)
299
+ value = value.value if value.is_a?(Sass::Script::Value::Number)
300
300
  return value if range.include?(value)
301
301
  return range.first if grace.include?(value - range.first)
302
302
  return range.last if grace.include?(value - range.last)
@@ -9,16 +9,16 @@ require 'pathname'
9
9
 
10
10
  module Sass::Script::Functions::UserFunctions
11
11
  def option(name)
12
- Sass::Script::String.new(@options[name.value.to_sym].to_s)
12
+ Sass::Script::Value::String.new(@options[name.value.to_sym].to_s)
13
13
  end
14
14
 
15
15
  def set_a_variable(name, value)
16
16
  environment.set_var(name.value, value)
17
- return Sass::Script::Null.new
17
+ return Sass::Script::Value::Null.new
18
18
  end
19
19
 
20
20
  def get_a_variable(name)
21
- environment.var(name.value) || Sass::Script::String.new("undefined")
21
+ environment.var(name.value) || Sass::Script::Value::String.new("undefined")
22
22
  end
23
23
  end
24
24
 
@@ -3032,9 +3032,9 @@ SCSS
3032
3032
  end
3033
3033
 
3034
3034
  def test_changing_precision
3035
- old_precision = Sass::Script::Number.precision
3035
+ old_precision = Sass::Script::Value::Number.precision
3036
3036
  begin
3037
- Sass::Script::Number.precision = 8
3037
+ Sass::Script::Value::Number.precision = 8
3038
3038
  assert_equal <<CSS, render(<<SASS)
3039
3039
  div {
3040
3040
  maximum: 1.00000001;
@@ -3045,7 +3045,7 @@ div
3045
3045
  too-much: 1.000000001
3046
3046
  SASS
3047
3047
  ensure
3048
- Sass::Script::Number.precision = old_precision
3048
+ Sass::Script::Value::Number.precision = old_precision
3049
3049
  end
3050
3050
  end
3051
3051
 
@@ -5,33 +5,33 @@ require 'sass/script'
5
5
 
6
6
  module Sass::Script::Functions
7
7
  def no_kw_args
8
- Sass::Script::String.new("no-kw-args")
8
+ Sass::Script::Value::String.new("no-kw-args")
9
9
  end
10
10
 
11
11
  def only_var_args(*args)
12
- Sass::Script::String.new("only-var-args("+args.map{|a| a.plus(Sass::Script::Number.new(1)).to_s }.join(", ")+")")
12
+ Sass::Script::Value::String.new("only-var-args("+args.map{|a| a.plus(Sass::Script::Value::Number.new(1)).to_s }.join(", ")+")")
13
13
  end
14
14
  declare :only_var_args, [], :var_args => true
15
15
 
16
16
  def only_kw_args(kwargs)
17
- Sass::Script::String.new("only-kw-args(" + kwargs.keys.map {|a| a.to_s}.sort.join(", ") + ")")
17
+ Sass::Script::Value::String.new("only-kw-args(" + kwargs.keys.map {|a| a.to_s}.sort.join(", ") + ")")
18
18
  end
19
19
  declare :only_kw_args, [], :var_kwargs => true
20
20
  end
21
21
 
22
22
  module Sass::Script::Functions::UserFunctions
23
- def call_options_on_new_literal
24
- str = Sass::Script::String.new("foo")
23
+ def call_options_on_new_value
24
+ str = Sass::Script::Value::String.new("foo")
25
25
  str.options[:foo]
26
26
  str
27
27
  end
28
28
 
29
29
  def user_defined
30
- Sass::Script::String.new("I'm a user-defined string!")
30
+ Sass::Script::Value::String.new("I'm a user-defined string!")
31
31
  end
32
32
 
33
33
  def _preceding_underscore
34
- Sass::Script::String.new("I'm another user-defined string!")
34
+ Sass::Script::Value::String.new("I'm another user-defined string!")
35
35
  end
36
36
 
37
37
  def fetch_the_variable
@@ -954,16 +954,16 @@ class SassFunctionTest < Test::Unit::TestCase
954
954
  end
955
955
 
956
956
  def test_user_defined_function_using_environment
957
- environment = env('variable' => Sass::Script::String.new('The variable'))
957
+ environment = env('variable' => Sass::Script::Value::String.new('The variable'))
958
958
  assert_equal("The variable", evaluate("fetch_the_variable()", environment))
959
959
  end
960
960
 
961
- def test_options_on_new_literals_fails
962
- assert_error_message(<<MSG, "call-options-on-new-literal()")
963
- The #options attribute is not set on this Sass::Script::String.
961
+ def test_options_on_new_values_fails
962
+ assert_error_message(<<MSG, "call-options-on-new-value()")
963
+ The #options attribute is not set on this Sass::Script::Value::String.
964
964
  This error is probably occurring because #to_s was called
965
- on this literal within a custom Sass function without first
966
- setting the #option attribute.
965
+ on this value within a custom Sass function without first
966
+ setting the #options attribute.
967
967
  MSG
968
968
  end
969
969
 
@@ -1199,32 +1199,32 @@ MSG
1199
1199
 
1200
1200
  def test_assert_unit
1201
1201
  ctx = Sass::Script::Functions::EvaluationContext.new(Sass::Environment.new(nil, {}))
1202
- ctx.assert_unit Sass::Script::Number.new(10, ["px"], []), "px"
1203
- ctx.assert_unit Sass::Script::Number.new(10, [], []), nil
1202
+ ctx.assert_unit Sass::Script::Value::Number.new(10, ["px"], []), "px"
1203
+ ctx.assert_unit Sass::Script::Value::Number.new(10, [], []), nil
1204
1204
 
1205
1205
  begin
1206
- ctx.assert_unit Sass::Script::Number.new(10, [], []), "px"
1206
+ ctx.assert_unit Sass::Script::Value::Number.new(10, [], []), "px"
1207
1207
  fail
1208
1208
  rescue ArgumentError => e
1209
1209
  assert_equal "Expected 10 to have a unit of px", e.message
1210
1210
  end
1211
1211
 
1212
1212
  begin
1213
- ctx.assert_unit Sass::Script::Number.new(10, ["px"], []), nil
1213
+ ctx.assert_unit Sass::Script::Value::Number.new(10, ["px"], []), nil
1214
1214
  fail
1215
1215
  rescue ArgumentError => e
1216
1216
  assert_equal "Expected 10px to be unitless", e.message
1217
1217
  end
1218
1218
 
1219
1219
  begin
1220
- ctx.assert_unit Sass::Script::Number.new(10, [], []), "px", "arg"
1220
+ ctx.assert_unit Sass::Script::Value::Number.new(10, [], []), "px", "arg"
1221
1221
  fail
1222
1222
  rescue ArgumentError => e
1223
1223
  assert_equal "Expected $arg to have a unit of px but got 10", e.message
1224
1224
  end
1225
1225
 
1226
1226
  begin
1227
- ctx.assert_unit Sass::Script::Number.new(10, ["px"], []), nil, "arg"
1227
+ ctx.assert_unit Sass::Script::Value::Number.new(10, ["px"], []), nil, "arg"
1228
1228
  fail
1229
1229
  rescue ArgumentError => e
1230
1230
  assert_equal "Expected $arg to be unitless but got 10px", e.message
@@ -1246,7 +1246,7 @@ MSG
1246
1246
 
1247
1247
  def evaluate(value, environment = env)
1248
1248
  result = perform(value, environment)
1249
- assert_kind_of Sass::Script::Literal, result
1249
+ assert_kind_of Sass::Script::Value::Base, result
1250
1250
  return result.to_s
1251
1251
  end
1252
1252
 
@@ -7,13 +7,13 @@ require 'fileutils'
7
7
  module Sass::Script::Functions
8
8
  def filename
9
9
  filename = options[:filename].gsub(%r{.*((/[^/]+){4})}, '\1')
10
- Sass::Script::String.new(filename)
10
+ Sass::Script::Value::String.new(filename)
11
11
  end
12
12
 
13
13
  def whatever
14
14
  custom = options[:custom]
15
15
  whatever = custom && custom[:whatever]
16
- Sass::Script::String.new(whatever || "incorrect")
16
+ Sass::Script::Value::String.new(whatever || "incorrect")
17
17
  end
18
18
  end
19
19
 
@@ -5,7 +5,7 @@ require 'sass/engine'
5
5
  module Sass::Script::Functions::UserFunctions
6
6
  def assert_options(val)
7
7
  val.options[:foo]
8
- Sass::Script::String.new("Options defined!")
8
+ Sass::Script::Value::String.new("Options defined!")
9
9
  end
10
10
 
11
11
  def arg_error
@@ -21,13 +21,13 @@ class SassScriptTest < Test::Unit::TestCase
21
21
  include Sass::Script
22
22
 
23
23
  def test_color_checks_input
24
- assert_raise_message(ArgumentError, "Blue value -1 must be between 0 and 255") {Color.new([1, 2, -1])}
25
- assert_raise_message(ArgumentError, "Red value 256 must be between 0 and 255") {Color.new([256, 2, 3])}
24
+ assert_raise_message(ArgumentError, "Blue value -1 must be between 0 and 255") {Sass::Script::Value::Color.new([1, 2, -1])}
25
+ assert_raise_message(ArgumentError, "Red value 256 must be between 0 and 255") {Sass::Script::Value::Color.new([256, 2, 3])}
26
26
  end
27
27
 
28
28
  def test_color_checks_rgba_input
29
- assert_raise_message(ArgumentError, "Alpha channel 1.1 must be between 0 and 1") {Color.new([1, 2, 3, 1.1])}
30
- assert_raise_message(ArgumentError, "Alpha channel -0.1 must be between 0 and 1") {Color.new([1, 2, 3, -0.1])}
29
+ assert_raise_message(ArgumentError, "Alpha channel 1.1 must be between 0 and 1") {Sass::Script::Value::Color.new([1, 2, 3, 1.1])}
30
+ assert_raise_message(ArgumentError, "Alpha channel -0.1 must be between 0 and 1") {Sass::Script::Value::Color.new([1, 2, 3, -0.1])}
31
31
  end
32
32
 
33
33
  def test_string_escapes
@@ -51,14 +51,14 @@ class SassScriptTest < Test::Unit::TestCase
51
51
  end
52
52
 
53
53
  def test_rgba_color_literals
54
- assert_equal Sass::Script::Color.new([1, 2, 3, 0.75]), eval("rgba(1, 2, 3, 0.75)")
54
+ assert_equal Sass::Script::Value::Color.new([1, 2, 3, 0.75]), eval("rgba(1, 2, 3, 0.75)")
55
55
  assert_equal "rgba(1, 2, 3, 0.75)", resolve("rgba(1, 2, 3, 0.75)")
56
56
 
57
- assert_equal Sass::Script::Color.new([1, 2, 3, 0]), eval("rgba(1, 2, 3, 0)")
57
+ assert_equal Sass::Script::Value::Color.new([1, 2, 3, 0]), eval("rgba(1, 2, 3, 0)")
58
58
  assert_equal "rgba(1, 2, 3, 0)", resolve("rgba(1, 2, 3, 0)")
59
59
 
60
- assert_equal Sass::Script::Color.new([1, 2, 3]), eval("rgba(1, 2, 3, 1)")
61
- assert_equal Sass::Script::Color.new([1, 2, 3, 1]), eval("rgba(1, 2, 3, 1)")
60
+ assert_equal Sass::Script::Value::Color.new([1, 2, 3]), eval("rgba(1, 2, 3, 1)")
61
+ assert_equal Sass::Script::Value::Color.new([1, 2, 3, 1]), eval("rgba(1, 2, 3, 1)")
62
62
  assert_equal "#010203", resolve("rgba(1, 2, 3, 1)")
63
63
  assert_equal "white", resolve("rgba(255, 255, 255, 1)")
64
64
  end
@@ -107,8 +107,8 @@ class SassScriptTest < Test::Unit::TestCase
107
107
  end
108
108
 
109
109
  def test_implicit_strings
110
- assert_equal Sass::Script::String.new("foo"), eval("foo")
111
- assert_equal Sass::Script::String.new("foo/bar"), eval("foo/bar")
110
+ assert_equal Sass::Script::Value::String.new("foo"), eval("foo")
111
+ assert_equal Sass::Script::Value::String.new("foo/bar"), eval("foo/bar")
112
112
  end
113
113
 
114
114
  def test_basic_interpolation
@@ -232,9 +232,9 @@ SASS
232
232
  end
233
233
 
234
234
  def test_dynamic_url
235
- assert_equal "url(foo-bar)", resolve("url($foo)", {}, env('foo' => Sass::Script::String.new("foo-bar")))
236
- assert_equal "url(foo-bar baz)", resolve("url($foo $bar)", {}, env('foo' => Sass::Script::String.new("foo-bar"), 'bar' => Sass::Script::String.new("baz")))
237
- assert_equal "url(foo baz)", resolve("url(foo $bar)", {}, env('bar' => Sass::Script::String.new("baz")))
235
+ assert_equal "url(foo-bar)", resolve("url($foo)", {}, env('foo' => Sass::Script::Value::String.new("foo-bar")))
236
+ assert_equal "url(foo-bar baz)", resolve("url($foo $bar)", {}, env('foo' => Sass::Script::Value::String.new("foo-bar"), 'bar' => Sass::Script::Value::String.new("baz")))
237
+ assert_equal "url(foo baz)", resolve("url(foo $bar)", {}, env('bar' => Sass::Script::Value::String.new("baz")))
238
238
  assert_equal "url(foo bar)", resolve("url(foo bar)")
239
239
  end
240
240
 
@@ -246,7 +246,7 @@ SASS
246
246
  end
247
247
 
248
248
  def test_hyphenated_variables
249
- assert_equal("a-b", resolve("$a-b", {}, env("a-b" => Sass::Script::String.new("a-b"))))
249
+ assert_equal("a-b", resolve("$a-b", {}, env("a-b" => Sass::Script::Value::String.new("a-b"))))
250
250
  end
251
251
 
252
252
  def test_ruby_equality
@@ -376,7 +376,7 @@ SASS
376
376
 
377
377
  def test_equals
378
378
  assert_equal("true", resolve('"foo" == $foo', {},
379
- env("foo" => Sass::Script::String.new("foo"))))
379
+ env("foo" => Sass::Script::Value::String.new("foo"))))
380
380
  assert_equal "true", resolve("1 == 1.0")
381
381
  assert_equal "true", resolve("false != true")
382
382
  assert_equal "false", resolve("1em == 1px")
@@ -507,8 +507,8 @@ SASS
507
507
  end
508
508
 
509
509
  def test_boolean_ops_short_circuit
510
- assert_equal "false", resolve("$ie and $ie <= 7", {}, env('ie' => Sass::Script::Bool.new(false)))
511
- assert_equal "true", resolve("$ie or $undef", {}, env('ie' => Sass::Script::Bool.new(true)))
510
+ assert_equal "false", resolve("$ie and $ie <= 7", {}, env('ie' => Sass::Script::Value::Bool.new(false)))
511
+ assert_equal "true", resolve("$ie or $undef", {}, env('ie' => Sass::Script::Value::Bool.new(true)))
512
512
  end
513
513
 
514
514
  # Regression Tests
@@ -542,16 +542,25 @@ SASS
542
542
  end
543
543
 
544
544
  def test_number_initialization
545
- assert_equal Sass::Script::Number.new(10, ["px"]), Sass::Script::Number.new(10, "px")
546
- assert_equal Sass::Script::Number.new(10, ["px"], ["em"]), Sass::Script::Number.new(10, "px", "em")
545
+ assert_equal Sass::Script::Value::Number.new(10, ["px"]), Sass::Script::Value::Number.new(10, "px")
546
+ assert_equal Sass::Script::Value::Number.new(10, ["px"], ["em"]), Sass::Script::Value::Number.new(10, "px", "em")
547
547
  end
548
548
 
549
549
  def test_is_unit
550
- assert Sass::Script::Number.new(10, "px").is_unit?("px")
551
- assert Sass::Script::Number.new(10).is_unit?(nil)
552
- assert !Sass::Script::Number.new(10, "px", "em").is_unit?("px")
553
- assert !Sass::Script::Number.new(10, [], "em").is_unit?("em")
554
- assert !Sass::Script::Number.new(10, ["px", "em"]).is_unit?("px")
550
+ assert Sass::Script::Value::Number.new(10, "px").is_unit?("px")
551
+ assert Sass::Script::Value::Number.new(10).is_unit?(nil)
552
+ assert !Sass::Script::Value::Number.new(10, "px", "em").is_unit?("px")
553
+ assert !Sass::Script::Value::Number.new(10, [], "em").is_unit?("em")
554
+ assert !Sass::Script::Value::Number.new(10, ["px", "em"]).is_unit?("px")
555
+ end
556
+
557
+ def test_rename_redirect
558
+ assert_no_warning do
559
+ assert_equal Sass::Script::Value::Base, Sass::Script::Literal
560
+ assert_equal Sass::Script::Tree::Node, Sass::Script::Node
561
+ assert_equal Sass::Script::Tree::Operation, Sass::Script::Operation
562
+ assert_equal Sass::Script::Value::String, Sass::Script::String
563
+ end
555
564
  end
556
565
 
557
566
  private
@@ -559,21 +568,21 @@ SASS
559
568
  def resolve(str, opts = {}, environment = env)
560
569
  munge_filename opts
561
570
  val = eval(str, opts, environment)
562
- assert_kind_of Sass::Script::Literal, val
563
- val.is_a?(Sass::Script::String) ? val.value : val.to_s
571
+ assert_kind_of Sass::Script::Value::Base, val
572
+ val.is_a?(Sass::Script::Value::String) ? val.value : val.to_s
564
573
  end
565
574
 
566
575
  def assert_unquoted(str, opts = {}, environment = env)
567
576
  munge_filename opts
568
577
  val = eval(str, opts, environment)
569
- assert_kind_of Sass::Script::String, val
578
+ assert_kind_of Sass::Script::Value::String, val
570
579
  assert_equal :identifier, val.type
571
580
  end
572
581
 
573
582
  def assert_quoted(str, opts = {}, environment = env)
574
583
  munge_filename opts
575
584
  val = eval(str, opts, environment)
576
- assert_kind_of Sass::Script::String, val
585
+ assert_kind_of Sass::Script::Value::String, val
577
586
  assert_equal :string, val.type
578
587
  end
579
588