haml 3.1.0 → 3.1.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of haml might be problematic. Click here for more details.

Files changed (87) hide show
  1. data/VERSION +1 -1
  2. data/vendor/sass/Rakefile +22 -46
  3. data/vendor/sass/VERSION +1 -1
  4. data/vendor/sass/VERSION_NAME +1 -1
  5. data/vendor/sass/bin/scss +8 -0
  6. data/vendor/sass/doc-src/SASS_CHANGELOG.md +125 -9
  7. data/vendor/sass/doc-src/SASS_REFERENCE.md +84 -8
  8. data/vendor/sass/lib/sass.rb +0 -3
  9. data/vendor/sass/lib/sass/cache_stores.rb +1 -0
  10. data/vendor/sass/lib/sass/cache_stores/base.rb +2 -2
  11. data/vendor/sass/lib/sass/cache_stores/chain.rb +33 -0
  12. data/vendor/sass/lib/sass/cache_stores/filesystem.rb +6 -4
  13. data/vendor/sass/lib/sass/cache_stores/memory.rb +8 -12
  14. data/vendor/sass/lib/sass/engine.rb +65 -56
  15. data/vendor/sass/lib/sass/environment.rb +5 -2
  16. data/vendor/sass/lib/sass/exec.rb +52 -21
  17. data/vendor/sass/lib/sass/importers/filesystem.rb +32 -9
  18. data/vendor/sass/lib/sass/less.rb +1 -1
  19. data/vendor/sass/lib/sass/plugin.rb +11 -1
  20. data/vendor/sass/lib/sass/plugin/compiler.rb +21 -12
  21. data/vendor/sass/lib/sass/plugin/rails.rb +8 -82
  22. data/vendor/sass/lib/sass/plugin/staleness_checker.rb +10 -10
  23. data/vendor/sass/lib/sass/railtie.rb +3 -2
  24. data/vendor/sass/lib/sass/script.rb +2 -25
  25. data/vendor/sass/lib/sass/script/color.rb +4 -15
  26. data/vendor/sass/lib/sass/script/funcall.rb +63 -19
  27. data/vendor/sass/lib/sass/script/functions.rb +257 -19
  28. data/vendor/sass/lib/sass/script/lexer.rb +1 -4
  29. data/vendor/sass/lib/sass/script/list.rb +2 -2
  30. data/vendor/sass/lib/sass/script/node.rb +0 -27
  31. data/vendor/sass/lib/sass/script/number.rb +1 -1
  32. data/vendor/sass/lib/sass/script/operation.rb +0 -5
  33. data/vendor/sass/lib/sass/script/parser.rb +30 -12
  34. data/vendor/sass/lib/sass/script/string.rb +2 -17
  35. data/vendor/sass/lib/sass/script/string_interpolation.rb +1 -0
  36. data/vendor/sass/lib/sass/scss/parser.rb +58 -18
  37. data/vendor/sass/lib/sass/scss/rx.rb +2 -1
  38. data/vendor/sass/lib/sass/scss/script_lexer.rb +1 -1
  39. data/vendor/sass/lib/sass/selector/comma_sequence.rb +2 -3
  40. data/vendor/sass/lib/sass/selector/sequence.rb +3 -6
  41. data/vendor/sass/lib/sass/selector/simple_sequence.rb +2 -3
  42. data/vendor/sass/lib/sass/tree/charset_node.rb +0 -15
  43. data/vendor/sass/lib/sass/tree/comment_node.rb +20 -71
  44. data/vendor/sass/lib/sass/tree/debug_node.rb +4 -22
  45. data/vendor/sass/lib/sass/tree/directive_node.rb +0 -52
  46. data/vendor/sass/lib/sass/tree/each_node.rb +8 -38
  47. data/vendor/sass/lib/sass/tree/extend_node.rb +12 -48
  48. data/vendor/sass/lib/sass/tree/for_node.rb +20 -51
  49. data/vendor/sass/lib/sass/tree/function_node.rb +27 -0
  50. data/vendor/sass/lib/sass/tree/if_node.rb +22 -57
  51. data/vendor/sass/lib/sass/tree/import_node.rb +0 -56
  52. data/vendor/sass/lib/sass/tree/media_node.rb +0 -43
  53. data/vendor/sass/lib/sass/tree/mixin_def_node.rb +12 -45
  54. data/vendor/sass/lib/sass/tree/mixin_node.rb +13 -124
  55. data/vendor/sass/lib/sass/tree/node.rb +18 -304
  56. data/vendor/sass/lib/sass/tree/prop_node.rb +24 -92
  57. data/vendor/sass/lib/sass/tree/return_node.rb +18 -0
  58. data/vendor/sass/lib/sass/tree/root_node.rb +4 -133
  59. data/vendor/sass/lib/sass/tree/rule_node.rb +21 -164
  60. data/vendor/sass/lib/sass/tree/variable_node.rb +14 -23
  61. data/vendor/sass/lib/sass/tree/visitors/base.rb +75 -0
  62. data/vendor/sass/lib/sass/tree/visitors/check_nesting.rb +134 -0
  63. data/vendor/sass/lib/sass/tree/visitors/convert.rb +255 -0
  64. data/vendor/sass/lib/sass/tree/visitors/cssize.rb +175 -0
  65. data/vendor/sass/lib/sass/tree/visitors/perform.rb +301 -0
  66. data/vendor/sass/lib/sass/tree/visitors/to_css.rb +216 -0
  67. data/vendor/sass/lib/sass/tree/warn_node.rb +4 -28
  68. data/vendor/sass/lib/sass/tree/while_node.rb +5 -35
  69. data/vendor/sass/lib/sass/util.rb +0 -50
  70. data/vendor/sass/sass.gemspec +1 -1
  71. data/vendor/sass/test/sass/conversion_test.rb +53 -102
  72. data/vendor/sass/test/sass/engine_test.rb +416 -540
  73. data/vendor/sass/test/sass/functions_test.rb +306 -4
  74. data/vendor/sass/test/sass/importer_test.rb +0 -22
  75. data/vendor/sass/test/sass/plugin_test.rb +51 -21
  76. data/vendor/sass/test/sass/results/if.css +3 -0
  77. data/vendor/sass/test/sass/script_conversion_test.rb +0 -38
  78. data/vendor/sass/test/sass/script_test.rb +19 -4
  79. data/vendor/sass/test/sass/scss/scss_test.rb +32 -11
  80. data/vendor/sass/test/sass/templates/if.sass +11 -0
  81. data/vendor/sass/test/sass/templates/nested_import.sass +2 -0
  82. data/vendor/sass/test/sass/util_test.rb +0 -21
  83. data/vendor/sass/test/test_helper.rb +0 -3
  84. metadata +268 -258
  85. data/vendor/sass/bin/css2sass +0 -13
  86. data/vendor/sass/lib/sass/cache_stores/active_support.rb +0 -28
  87. data/vendor/sass/lib/sass/importers/rails.rb +0 -75
@@ -35,6 +35,10 @@ module Sass::Script::Functions::UserFunctions
35
35
  end
36
36
  end
37
37
 
38
+ module Sass::Script::Functions
39
+ include Sass::Script::Functions::UserFunctions
40
+ end
41
+
38
42
  class SassFunctionTest < Test::Unit::TestCase
39
43
  # Tests taken from:
40
44
  # http://www.w3.org/Style/CSS/Test/CSS3/Color/20070927/html4/t040204-hsl-h-rotating-b.htm
@@ -461,6 +465,276 @@ class SassFunctionTest < Test::Unit::TestCase
461
465
  assert_error_message("\"foo\" is not a number for `adjust-hue'", "adjust-hue(#fff, \"foo\")")
462
466
  end
463
467
 
468
+ def test_adjust_color
469
+ # HSL
470
+ assert_equal(evaluate("hsl(180, 30, 90)"),
471
+ evaluate("adjust-color(hsl(120, 30, 90), $hue: 60deg)"))
472
+ assert_equal(evaluate("hsl(120, 50, 90)"),
473
+ evaluate("adjust-color(hsl(120, 30, 90), $saturation: 20%)"))
474
+ assert_equal(evaluate("hsl(120, 30, 60)"),
475
+ evaluate("adjust-color(hsl(120, 30, 90), $lightness: -30%)"))
476
+ # RGB
477
+ assert_equal(evaluate("rgb(15, 20, 30)"),
478
+ evaluate("adjust-color(rgb(10, 20, 30), $red: 5)"))
479
+ assert_equal(evaluate("rgb(10, 15, 30)"),
480
+ evaluate("adjust-color(rgb(10, 20, 30), $green: -5)"))
481
+ assert_equal(evaluate("rgb(10, 20, 40)"),
482
+ evaluate("adjust-color(rgb(10, 20, 30), $blue: 10)"))
483
+ # Alpha
484
+ assert_equal(evaluate("hsla(120, 30, 90, 0.65)"),
485
+ evaluate("adjust-color(hsl(120, 30, 90), $alpha: -0.35)"))
486
+ assert_equal(evaluate("rgba(10, 20, 30, 0.9)"),
487
+ evaluate("adjust-color(rgba(10, 20, 30, 0.4), $alpha: 0.5)"))
488
+
489
+ # HSL composability
490
+ assert_equal(evaluate("hsl(180, 20, 90)"),
491
+ evaluate("adjust-color(hsl(120, 30, 90), $hue: 60deg, $saturation: -10%)"))
492
+ assert_equal(evaluate("hsl(180, 20, 95)"),
493
+ evaluate("adjust-color(hsl(120, 30, 90), $hue: 60deg, $saturation: -10%, $lightness: 5%)"))
494
+ assert_equal(evaluate("hsla(120, 20, 95, 0.3)"),
495
+ evaluate("adjust-color(hsl(120, 30, 90), $saturation: -10%, $lightness: 5%, $alpha: -0.7)"))
496
+
497
+ # RGB composability
498
+ assert_equal(evaluate("rgb(15, 20, 29)"),
499
+ evaluate("adjust-color(rgb(10, 20, 30), $red: 5, $blue: -1)"))
500
+ assert_equal(evaluate("rgb(15, 45, 29)"),
501
+ evaluate("adjust-color(rgb(10, 20, 30), $red: 5, $green: 25, $blue: -1)"))
502
+ assert_equal(evaluate("rgba(10, 25, 29, 0.7)"),
503
+ evaluate("adjust-color(rgb(10, 20, 30), $green: 5, $blue: -1, $alpha: -0.3)"))
504
+
505
+ # HSL range restriction
506
+ assert_equal(evaluate("hsl(120, 30, 90)"),
507
+ evaluate("adjust-color(hsl(120, 30, 90), $hue: 720deg)"))
508
+ assert_equal(evaluate("hsl(120, 0, 90)"),
509
+ evaluate("adjust-color(hsl(120, 30, 90), $saturation: -90%)"))
510
+ assert_equal(evaluate("hsl(120, 30, 100)"),
511
+ evaluate("adjust-color(hsl(120, 30, 90), $lightness: 30%)"))
512
+
513
+ # RGB range restriction
514
+ assert_equal(evaluate("rgb(255, 20, 30)"),
515
+ evaluate("adjust-color(rgb(10, 20, 30), $red: 250)"))
516
+ assert_equal(evaluate("rgb(10, 0, 30)"),
517
+ evaluate("adjust-color(rgb(10, 20, 30), $green: -30)"))
518
+ assert_equal(evaluate("rgb(10, 20, 0)"),
519
+ evaluate("adjust-color(rgb(10, 20, 30), $blue: -40)"))
520
+ end
521
+
522
+ def test_adjust_color_tests_types
523
+ assert_error_message("\"foo\" is not a color for `adjust-color'", "adjust-color(foo, $hue: 10)")
524
+ # HSL
525
+ assert_error_message("$hue: \"foo\" is not a number for `adjust-color'",
526
+ "adjust-color(blue, $hue: foo)")
527
+ assert_error_message("$saturation: \"foo\" is not a number for `adjust-color'",
528
+ "adjust-color(blue, $saturation: foo)")
529
+ assert_error_message("$lightness: \"foo\" is not a number for `adjust-color'",
530
+ "adjust-color(blue, $lightness: foo)")
531
+ # RGB
532
+ assert_error_message("$red: \"foo\" is not a number for `adjust-color'",
533
+ "adjust-color(blue, $red: foo)")
534
+ assert_error_message("$green: \"foo\" is not a number for `adjust-color'",
535
+ "adjust-color(blue, $green: foo)")
536
+ assert_error_message("$blue: \"foo\" is not a number for `adjust-color'",
537
+ "adjust-color(blue, $blue: foo)")
538
+ # Alpha
539
+ assert_error_message("$alpha: \"foo\" is not a number for `adjust-color'",
540
+ "adjust-color(blue, $alpha: foo)")
541
+ end
542
+
543
+ def test_adjust_color_tests_arg_range
544
+ # HSL
545
+ assert_error_message("$saturation: Amount 101% must be between -100% and 100% for `adjust-color'",
546
+ "adjust-color(blue, $saturation: 101%)")
547
+ assert_error_message("$saturation: Amount -101% must be between -100% and 100% for `adjust-color'",
548
+ "adjust-color(blue, $saturation: -101%)")
549
+ assert_error_message("$lightness: Amount 101% must be between -100% and 100% for `adjust-color'",
550
+ "adjust-color(blue, $lightness: 101%)")
551
+ assert_error_message("$lightness: Amount -101% must be between -100% and 100% for `adjust-color'",
552
+ "adjust-color(blue, $lightness: -101%)")
553
+ # RGB
554
+ assert_error_message("$red: Amount 256 must be between -255 and 255 for `adjust-color'",
555
+ "adjust-color(blue, $red: 256)")
556
+ assert_error_message("$red: Amount -256 must be between -255 and 255 for `adjust-color'",
557
+ "adjust-color(blue, $red: -256)")
558
+ assert_error_message("$green: Amount 256 must be between -255 and 255 for `adjust-color'",
559
+ "adjust-color(blue, $green: 256)")
560
+ assert_error_message("$green: Amount -256 must be between -255 and 255 for `adjust-color'",
561
+ "adjust-color(blue, $green: -256)")
562
+ assert_error_message("$blue: Amount 256 must be between -255 and 255 for `adjust-color'",
563
+ "adjust-color(blue, $blue: 256)")
564
+ assert_error_message("$blue: Amount -256 must be between -255 and 255 for `adjust-color'",
565
+ "adjust-color(blue, $blue: -256)")
566
+ # Alpha
567
+ assert_error_message("$alpha: Amount 1.1 must be between -1 and 1 for `adjust-color'",
568
+ "adjust-color(blue, $alpha: 1.1)")
569
+ assert_error_message("$alpha: Amount -1.1 must be between -1 and 1 for `adjust-color'",
570
+ "adjust-color(blue, $alpha: -1.1)")
571
+ end
572
+
573
+ def test_adjust_color_argument_errors
574
+ assert_error_message("Unknown argument $hoo (260deg) for `adjust-color'",
575
+ "adjust-color(blue, $hoo: 260deg)")
576
+ assert_error_message("Cannot specify HSL and RGB values for a color at the same time for `adjust-color'",
577
+ "adjust-color(blue, $hue: 120deg, $red: 10)");
578
+ assert_error_message("10px is not a keyword argument for `adjust_color'",
579
+ "adjust-color(blue, 10px)")
580
+ assert_error_message("10px is not a keyword argument for `adjust_color'",
581
+ "adjust-color(blue, 10px, 20px)")
582
+ assert_error_message("10px is not a keyword argument for `adjust_color'",
583
+ "adjust-color(blue, 10px, $hue: 180deg)")
584
+ end
585
+
586
+ def test_scale_color
587
+ # HSL
588
+ assert_equal(evaluate("hsl(120, 51, 90)"),
589
+ evaluate("scale-color(hsl(120, 30, 90), $saturation: 30%)"))
590
+ assert_equal(evaluate("hsl(120, 30, 76.5)"),
591
+ evaluate("scale-color(hsl(120, 30, 90), $lightness: -15%)"))
592
+ # RGB
593
+ assert_equal(evaluate("rgb(157, 20, 30)"),
594
+ evaluate("scale-color(rgb(10, 20, 30), $red: 60%)"))
595
+ assert_equal(evaluate("rgb(10, 38.8, 30)"),
596
+ evaluate("scale-color(rgb(10, 20, 30), $green: 8%)"))
597
+ assert_equal(evaluate("rgb(10, 20, 20)"),
598
+ evaluate("scale-color(rgb(10, 20, 30), $blue: -(1/3)*100%)"))
599
+ # Alpha
600
+ assert_equal(evaluate("hsla(120, 30, 90, 0.86)"),
601
+ evaluate("scale-color(hsl(120, 30, 90), $alpha: -14%)"))
602
+ assert_equal(evaluate("rgba(10, 20, 30, 0.82)"),
603
+ evaluate("scale-color(rgba(10, 20, 30, 0.8), $alpha: 10%)"))
604
+
605
+ # HSL composability
606
+ assert_equal(evaluate("hsl(120, 51, 76.5)"),
607
+ evaluate("scale-color(hsl(120, 30, 90), $saturation: 30%, $lightness: -15%)"))
608
+ assert_equal(evaluate("hsla(120, 51, 90, 0.2)"),
609
+ evaluate("scale-color(hsl(120, 30, 90), $saturation: 30%, $alpha: -80%)"))
610
+
611
+ # RGB composability
612
+ assert_equal(evaluate("rgb(157, 38.8, 30)"),
613
+ evaluate("scale-color(rgb(10, 20, 30), $red: 60%, $green: 8%)"))
614
+ assert_equal(evaluate("rgb(157, 38.8, 20)"),
615
+ evaluate("scale-color(rgb(10, 20, 30), $red: 60%, $green: 8%, $blue: -(1/3)*100%)"))
616
+ assert_equal(evaluate("rgba(10, 38.8, 20, 0.55)"),
617
+ evaluate("scale-color(rgba(10, 20, 30, 0.5), $green: 8%, $blue: -(1/3)*100%, $alpha: 10%)"))
618
+
619
+ # Extremes
620
+ assert_equal(evaluate("hsl(120, 100, 90)"),
621
+ evaluate("scale-color(hsl(120, 30, 90), $saturation: 100%)"))
622
+ assert_equal(evaluate("hsl(120, 30, 90)"),
623
+ evaluate("scale-color(hsl(120, 30, 90), $saturation: 0%)"))
624
+ assert_equal(evaluate("hsl(120, 0, 90)"),
625
+ evaluate("scale-color(hsl(120, 30, 90), $saturation: -100%)"))
626
+ end
627
+
628
+ def test_scale_color_tests_types
629
+ assert_error_message("\"foo\" is not a color for `scale-color'", "scale-color(foo, $red: 10%)")
630
+ # HSL
631
+ assert_error_message("$saturation: \"foo\" is not a number for `scale-color'",
632
+ "scale-color(blue, $saturation: foo)")
633
+ assert_error_message("$lightness: \"foo\" is not a number for `scale-color'",
634
+ "scale-color(blue, $lightness: foo)")
635
+ # RGB
636
+ assert_error_message("$red: \"foo\" is not a number for `scale-color'",
637
+ "scale-color(blue, $red: foo)")
638
+ assert_error_message("$green: \"foo\" is not a number for `scale-color'",
639
+ "scale-color(blue, $green: foo)")
640
+ assert_error_message("$blue: \"foo\" is not a number for `scale-color'",
641
+ "scale-color(blue, $blue: foo)")
642
+ # Alpha
643
+ assert_error_message("$alpha: \"foo\" is not a number for `scale-color'",
644
+ "scale-color(blue, $alpha: foo)")
645
+ end
646
+
647
+ def test_scale_color_argument_errors
648
+ # Range
649
+ assert_error_message("$saturation: Amount 101% must be between -100% and 100% for `scale-color'",
650
+ "scale-color(blue, $saturation: 101%)")
651
+ assert_error_message("$red: Amount -101% must be between -100% and 100% for `scale-color'",
652
+ "scale-color(blue, $red: -101%)")
653
+ assert_error_message("$alpha: Amount -101% must be between -100% and 100% for `scale-color'",
654
+ "scale-color(blue, $alpha: -101%)")
655
+
656
+ # Unit
657
+ assert_error_message("$saturation: Amount 80 must be a % (e.g. 80%) for `scale-color'",
658
+ "scale-color(blue, $saturation: 80)")
659
+ assert_error_message("$alpha: Amount 0.5 must be a % (e.g. 0.5%) for `scale-color'",
660
+ "scale-color(blue, $alpha: 0.5)")
661
+
662
+ # Unknown argument
663
+ assert_error_message("Unknown argument $hue (80%) for `scale-color'", "scale-color(blue, $hue: 80%)")
664
+
665
+ # Non-keyword arg
666
+ assert_error_message("10px is not a keyword argument for `scale_color'", "scale-color(blue, 10px)")
667
+
668
+ # HSL/RGB
669
+ assert_error_message("Cannot specify HSL and RGB values for a color at the same time for `scale-color'",
670
+ "scale-color(blue, $lightness: 10%, $red: 20%)");
671
+ end
672
+
673
+ def test_change_color
674
+ # HSL
675
+ assert_equal(evaluate("hsl(195, 30, 90)"),
676
+ evaluate("change-color(hsl(120, 30, 90), $hue: 195deg)"))
677
+ assert_equal(evaluate("hsl(120, 50, 90)"),
678
+ evaluate("change-color(hsl(120, 30, 90), $saturation: 50%)"))
679
+ assert_equal(evaluate("hsl(120, 30, 40)"),
680
+ evaluate("change-color(hsl(120, 30, 90), $lightness: 40%)"))
681
+ # RGB
682
+ assert_equal(evaluate("rgb(123, 20, 30)"),
683
+ evaluate("change-color(rgb(10, 20, 30), $red: 123)"))
684
+ assert_equal(evaluate("rgb(10, 234, 30)"),
685
+ evaluate("change-color(rgb(10, 20, 30), $green: 234)"))
686
+ assert_equal(evaluate("rgb(10, 20, 198)"),
687
+ evaluate("change-color(rgb(10, 20, 30), $blue: 198)"))
688
+ # Alpha
689
+ assert_equal(evaluate("rgba(10, 20, 30, 0.76)"),
690
+ evaluate("change-color(rgb(10, 20, 30), $alpha: 0.76)"))
691
+
692
+ # HSL composability
693
+ assert_equal(evaluate("hsl(56, 30, 47)"),
694
+ evaluate("change-color(hsl(120, 30, 90), $hue: 56deg, $lightness: 47%)"))
695
+ assert_equal(evaluate("hsla(56, 30, 47, 0.9)"),
696
+ evaluate("change-color(hsl(120, 30, 90), $hue: 56deg, $lightness: 47%, $alpha: 0.9)"))
697
+ end
698
+
699
+ def test_change_color_tests_types
700
+ assert_error_message("\"foo\" is not a color for `change-color'", "change-color(foo, $red: 10%)")
701
+ # HSL
702
+ assert_error_message("$saturation: \"foo\" is not a number for `change-color'",
703
+ "change-color(blue, $saturation: foo)")
704
+ assert_error_message("$lightness: \"foo\" is not a number for `change-color'",
705
+ "change-color(blue, $lightness: foo)")
706
+ # RGB
707
+ assert_error_message("$red: \"foo\" is not a number for `change-color'", "change-color(blue, $red: foo)")
708
+ assert_error_message("$green: \"foo\" is not a number for `change-color'", "change-color(blue, $green: foo)")
709
+ assert_error_message("$blue: \"foo\" is not a number for `change-color'", "change-color(blue, $blue: foo)")
710
+ # Alpha
711
+ assert_error_message("$alpha: \"foo\" is not a number for `change-color'", "change-color(blue, $alpha: foo)")
712
+ end
713
+
714
+ def test_change_color_argument_errors
715
+ # Range
716
+ assert_error_message("Saturation must be between 0 and 100 for `change-color'",
717
+ "change-color(blue, $saturation: 101%)")
718
+ assert_error_message("Lightness must be between 0 and 100 for `change-color'",
719
+ "change-color(blue, $lightness: 101%)")
720
+ assert_error_message("Red value must be between 0 and 255 for `change-color'",
721
+ "change-color(blue, $red: -1)")
722
+ assert_error_message("Green value must be between 0 and 255 for `change-color'",
723
+ "change-color(blue, $green: 256)")
724
+ assert_error_message("Blue value must be between 0 and 255 for `change-color'",
725
+ "change-color(blue, $blue: 500)")
726
+
727
+ # Unknown argument
728
+ assert_error_message("Unknown argument $hoo (80%) for `change-color'", "change-color(blue, $hoo: 80%)")
729
+
730
+ # Non-keyword arg
731
+ assert_error_message("10px is not a keyword argument for `change_color'", "change-color(blue, 10px)")
732
+
733
+ # HSL/RGB
734
+ assert_error_message("Cannot specify HSL and RGB values for a color at the same time for `change-color'",
735
+ "change-color(blue, $lightness: 10%, $red: 120)");
736
+ end
737
+
464
738
  def test_mix
465
739
  assert_equal("#7f007f", evaluate("mix(#f00, #00f)"))
466
740
  assert_equal("#7f7f7f", evaluate("mix(#f00, #0ff)"))
@@ -532,10 +806,6 @@ class SassFunctionTest < Test::Unit::TestCase
532
806
  assert_equal('foo', evaluate('unquote($string: foo)'))
533
807
  end
534
808
 
535
- def test_unquote_tests_type
536
- assert_error_message("#ff0000 is not a string for `unquote'", "unquote(#f00)")
537
- end
538
-
539
809
  def test_quote
540
810
  assert_equal('"foo"', evaluate('quote(foo)'))
541
811
  assert_equal('"foo"', evaluate('quote("foo")'))
@@ -605,6 +875,8 @@ MSG
605
875
  assert_equal("3", evaluate("length((foo, bar, baz bip))"))
606
876
  assert_equal("3", evaluate("length((foo, bar, (baz, bip)))"))
607
877
  assert_equal("1", evaluate("length(#f00)"))
878
+ assert_equal("0", evaluate("length(())"))
879
+ assert_equal("4", evaluate("length(1 2 () 3)"))
608
880
  end
609
881
 
610
882
  def test_nth
@@ -618,6 +890,7 @@ MSG
618
890
  assert_error_message("List index 1.5 must be an integer for `nth'", "nth(foo, 1.5)")
619
891
  assert_error_message("List index is 5 but list is only 4 items long for `nth'", "nth(1 2 3 4, 5)")
620
892
  assert_error_message("List index is 2 but list is only 1 item long for `nth'", "nth(foo, 2)")
893
+ assert_error_message("List index is 1 but list has no items for `nth'", "nth((), 1)")
621
894
  end
622
895
 
623
896
  def test_join
@@ -641,6 +914,20 @@ MSG
641
914
  assert_equal("1 2 3 4", evaluate("join((1, 2), (3, 4), space)"))
642
915
  assert_equal("1, 2", evaluate("join(1, 2, comma)"))
643
916
 
917
+ assert_equal("1 2", evaluate("join(1 2, ())"))
918
+ assert_equal("1, 2", evaluate("join((1, 2), ())"))
919
+ assert_equal("true", evaluate("(1 2) == join(1 2, ())"))
920
+ assert_equal("true", evaluate("(1, 2) == join((1, 2), ())"))
921
+ assert_equal("false", evaluate("(1 2 ()) == join(1 2, ())"))
922
+ assert_equal("false", evaluate("(1, 2, ()) == join((1, 2), ())"))
923
+
924
+ assert_equal("1 2", evaluate("join((), 1 2)"))
925
+ assert_equal("1, 2", evaluate("join((), (1, 2))"))
926
+ assert_equal("true", evaluate("(1 2) == join((), 1 2)"))
927
+ assert_equal("true", evaluate("(1, 2) == join((), (1, 2))"))
928
+ assert_equal("false", evaluate("(1 2 ()) == join((), 1 2)"))
929
+ assert_equal("false", evaluate("(1, 2, ()) == join((), (1, 2))"))
930
+
644
931
  assert_error_message("Separator name must be space, comma, or auto for `join'", "join(1, 2, baboon)")
645
932
  end
646
933
 
@@ -665,9 +952,24 @@ MSG
665
952
  assert_equal("1 2 3, 4", evaluate("append((1, 2), (3, 4), space)"))
666
953
  assert_equal("1, 2", evaluate("append(1, 2, comma)"))
667
954
 
955
+ assert_equal("1 2", evaluate("append(1 2, ())"))
956
+ assert_equal("1, 2", evaluate("append((1, 2), ())"))
957
+ assert_equal("true", evaluate("(1 2 ()) == append(1 2, ())"))
958
+ assert_equal("true", evaluate("(1, 2, ()) == append((1, 2), ())"))
959
+
960
+ assert_equal("1 2", evaluate("append((), 1 2)"))
961
+ assert_equal("1, 2", evaluate("append((), (1, 2))"))
962
+ assert_equal("false", evaluate("(1 2) == append((), 1 2)"))
963
+ assert_equal("true", evaluate("(1 2) == nth(append((), 1 2), 1)"))
964
+
668
965
  assert_error_message("Separator name must be space, comma, or auto for `append'", "append(1, 2, baboon)")
669
966
  end
670
967
 
968
+ def test_if
969
+ assert_equal("1px", evaluate("if(true, 1px, 2px)"))
970
+ assert_equal("2px", evaluate("if(false, 1px, 2px)"))
971
+ end
972
+
671
973
  def test_keyword_args_rgb
672
974
  assert_equal(%Q{white}, evaluate("rgb($red: 255, $green: 255, $blue: 255)"))
673
975
  end
@@ -5,8 +5,6 @@ require File.dirname(__FILE__) + '/test_helper'
5
5
  class ImporterTest < Test::Unit::TestCase
6
6
 
7
7
  class FruitImporter < Sass::Importers::Base
8
- attr_reader :cached
9
-
10
8
  def find(name, context = nil)
11
9
  if name =~ %r{fruits/(\w+)(\.s[ac]ss)?}
12
10
  fruit = $1
@@ -31,13 +29,6 @@ class ImporterTest < Test::Unit::TestCase
31
29
  def key(name, context)
32
30
  [self.class.name, name]
33
31
  end
34
-
35
- def _around_dump
36
- @cached = true
37
- yield
38
- ensure
39
- @cached = false
40
- end
41
32
  end
42
33
 
43
34
  # This class proves that you can override the extension scheme for importers
@@ -88,17 +79,4 @@ CSS
88
79
  ensure
89
80
  FileUtils.rm_rf(absolutize("tmp"))
90
81
  end
91
-
92
- def test_caching_importer
93
- source = "p\n foo: bar"
94
- importer = FruitImporter.new
95
- filename = filename_for_test
96
- engine = Sass::Engine.new(source, :filename => filename, :importer => importer)
97
- engine.to_tree # Trigger caching
98
-
99
- sha = Digest::SHA1.hexdigest(source)
100
- cache = engine.options[:cache_store]
101
- cached_tree = cache.retrieve(cache.key(*importer.key(filename, engine.options)), sha)
102
- assert cached_tree.options[:importer].cached, "Importer's _around_dump method should have been called"
103
- end
104
82
  end
@@ -19,7 +19,7 @@ class SassPluginTest < Test::Unit::TestCase
19
19
  FileUtils.mkdir_p tempfile_loc
20
20
  FileUtils.mkdir_p tempfile_loc(nil,"more_")
21
21
  set_plugin_opts
22
- update_all_stylesheets!
22
+ check_for_updates!
23
23
  reset_mtimes
24
24
  end
25
25
 
@@ -39,21 +39,21 @@ class SassPluginTest < Test::Unit::TestCase
39
39
  def test_no_update
40
40
  File.delete(tempfile_loc('basic'))
41
41
  assert_needs_update 'basic'
42
- update_all_stylesheets!
42
+ check_for_updates!
43
43
  assert_stylesheet_updated 'basic'
44
44
  end
45
45
 
46
46
  def test_update_needed_when_modified
47
47
  touch 'basic'
48
48
  assert_needs_update 'basic'
49
- update_all_stylesheets!
49
+ check_for_updates!
50
50
  assert_stylesheet_updated 'basic'
51
51
  end
52
52
 
53
53
  def test_update_needed_when_dependency_modified
54
54
  touch 'basic'
55
55
  assert_needs_update 'import'
56
- update_all_stylesheets!
56
+ check_for_updates!
57
57
  assert_stylesheet_updated 'basic'
58
58
  assert_stylesheet_updated 'import'
59
59
  end
@@ -61,7 +61,7 @@ class SassPluginTest < Test::Unit::TestCase
61
61
  def test_update_needed_when_scss_dependency_modified
62
62
  touch 'scss_importee'
63
63
  assert_needs_update 'import'
64
- update_all_stylesheets!
64
+ check_for_updates!
65
65
  assert_stylesheet_updated 'scss_importee'
66
66
  assert_stylesheet_updated 'import'
67
67
  end
@@ -69,14 +69,34 @@ class SassPluginTest < Test::Unit::TestCase
69
69
  def test_scss_update_needed_when_dependency_modified
70
70
  touch 'basic'
71
71
  assert_needs_update 'scss_import'
72
- update_all_stylesheets!
72
+ check_for_updates!
73
73
  assert_stylesheet_updated 'basic'
74
74
  assert_stylesheet_updated 'scss_import'
75
75
  end
76
76
 
77
+ def test_update_needed_when_nested_import_dependency_modified
78
+ touch 'basic'
79
+ assert_needs_update 'nested_import'
80
+ check_for_updates!
81
+ assert_stylesheet_updated 'basic'
82
+ assert_stylesheet_updated 'scss_import'
83
+ end
84
+
85
+ def test_no_updates_when_always_check_and_always_update_both_false
86
+ Sass::Plugin.options[:always_update] = false
87
+ Sass::Plugin.options[:always_check] = false
88
+
89
+ touch 'basic'
90
+ assert_needs_update 'basic'
91
+ check_for_updates!
92
+
93
+ # Check it's still stale
94
+ assert_needs_update 'basic'
95
+ end
96
+
77
97
  def test_full_exception_handling
78
98
  File.delete(tempfile_loc('bork1'))
79
- update_all_stylesheets!
99
+ check_for_updates!
80
100
  File.open(tempfile_loc('bork1')) do |file|
81
101
  assert_equal(<<CSS.strip, file.read.split("\n")[0...6].join("\n"))
82
102
  /*
@@ -95,17 +115,17 @@ CSS
95
115
  Sass::Plugin.options[:full_exception] = false
96
116
 
97
117
  File.delete(tempfile_loc('bork1'))
98
- assert_raise(Sass::SyntaxError) {update_all_stylesheets!}
118
+ assert_raise(Sass::SyntaxError) {check_for_updates!}
99
119
  ensure
100
120
  Sass::Plugin.options[:full_exception] = old_full_exception
101
121
  end
102
-
122
+
103
123
  def test_two_template_directories
104
124
  set_plugin_opts :template_location => {
105
125
  template_loc => tempfile_loc,
106
126
  template_loc(nil,'more_') => tempfile_loc(nil,'more_')
107
127
  }
108
- update_all_stylesheets!
128
+ check_for_updates!
109
129
  ['more1', 'more_import'].each { |name| assert_renders_correctly(name, :prefix => 'more_') }
110
130
  end
111
131
 
@@ -116,7 +136,7 @@ CSS
116
136
  template_loc => tempfile_loc,
117
137
  template_loc(nil,'more_') => tempfile_loc(nil,'more_')
118
138
  }
119
- update_all_stylesheets!
139
+ check_for_updates!
120
140
  assert_renders_correctly('more1_with_line_comments', 'more1', :prefix => 'more_')
121
141
  end
122
142
 
@@ -138,7 +158,7 @@ CSS
138
158
  touch 'basic'
139
159
  assert_needs_update "more1", "more_"
140
160
  assert_needs_update "basic"
141
- update_all_stylesheets!
161
+ check_for_updates!
142
162
  assert_doesnt_need_update "more1", "more_"
143
163
  assert_doesnt_need_update "basic"
144
164
  end
@@ -154,7 +174,7 @@ CSS
154
174
  touch 'basic'
155
175
  assert_needs_update "more1", "more_"
156
176
  assert_needs_update "basic"
157
- update_all_stylesheets!
177
+ check_for_updates!
158
178
  assert_doesnt_need_update "more1", "more_"
159
179
  assert_needs_update "basic"
160
180
  end
@@ -259,7 +279,7 @@ CSS
259
279
 
260
280
  touch 'basic', 'more_'
261
281
  assert_needs_update "import"
262
- update_all_stylesheets!
282
+ check_for_updates!
263
283
  assert_renders_correctly("import")
264
284
  ensure
265
285
  FileUtils.mv(template_loc("basic", "more_"), template_loc("basic"))
@@ -268,12 +288,22 @@ CSS
268
288
  def test_cached_relative_import
269
289
  old_always_update = Sass::Plugin.options[:always_update]
270
290
  Sass::Plugin.options[:always_update] = true
271
- update_all_stylesheets!
291
+ check_for_updates!
272
292
  assert_renders_correctly('subdir/subdir')
273
293
  ensure
274
294
  Sass::Plugin.options[:always_update] = old_always_update
275
295
  end
276
296
 
297
+ def test_cached_if
298
+ set_plugin_opts :cache_store => Sass::CacheStores::Filesystem.new(tempfile_loc + '/cache')
299
+ check_for_updates!
300
+ assert_renders_correctly 'if'
301
+ check_for_updates!
302
+ assert_renders_correctly 'if'
303
+ ensure
304
+ set_plugin_opts :cache_store => @@cache_store
305
+ end
306
+
277
307
  private
278
308
 
279
309
  def assert_renders_correctly(*arguments)
@@ -326,7 +356,7 @@ CSS
326
356
  if block_given?
327
357
  yield
328
358
  else
329
- update_all_stylesheets!
359
+ check_for_updates!
330
360
  end
331
361
 
332
362
  assert run, "Expected #{name} callback to be run with arguments:\n #{expected_args.inspect}"
@@ -349,23 +379,23 @@ CSS
349
379
  if block_given?
350
380
  yield
351
381
  else
352
- update_all_stylesheets!
382
+ check_for_updates!
353
383
  end
354
384
  end
355
385
 
356
386
  def assert_callbacks(*args)
357
- return update_all_stylesheets! if args.empty?
387
+ return check_for_updates! if args.empty?
358
388
  assert_callback(*args.pop) {assert_callbacks(*args)}
359
389
  end
360
390
 
361
391
  def assert_no_callbacks(*args)
362
- return update_all_stylesheets! if args.empty?
392
+ return check_for_updates! if args.empty?
363
393
  assert_no_callback(*args.pop) {assert_no_callbacks(*args)}
364
394
  end
365
395
 
366
- def update_all_stylesheets!
396
+ def check_for_updates!
367
397
  Sass::Util.silence_sass_warnings do
368
- Sass::Plugin.update_stylesheets
398
+ Sass::Plugin.check_for_updates
369
399
  end
370
400
  end
371
401