Test your Sass off

1 @function test( $statement , $assertion , $expectation ) {
2 @if $assertion != $expectation {
3 $result : "FAIL" ;
4 @return "____ #{ $result } ____ " + $statement + " ____ Expected #{ $assertion } to equal EXPECTATION: #{ $expectation }" ;
5 }
6 @if $assertion == $expectation {
7 $result : "PASS" ;
8 @return "____ #{ $result } ____ " + $statement ;
9 }
10 }

11

12 // example usage
13
14 @debug test( "draw_pixel creates box-shadow based off of $width " , draw_pixel(1, $hair ), "6px 0px #090909" );
15
16 @debug test( "draw_pixel creates a number of box-shadow css output equal to the length" , draw_pixel(3, $hair ), "18px 0px #090909" );
17
18 @debug test( "function DRAW_LINE: creates box-shadow based off of span.var$width" , draw_line(0, 1, $hair ), "6px 0px #090909" );
19
20 @debug test( "draw_line creates a number of box-shadow css output equal to the length",draw_line(3, 3, $hair ), "24px 0px #090909,30px 0px #090909,36px 0px #090909" );
21
22 @debug test( "draw_row draws a pixel for each block" , draw_row(4, $lengths : (2,1,2), $colors : ( $hair , $crown-gold , $hair )), "30px 0px #090909,36px 0px #090909,42px 0px #f5d858,48px 0px #090909,54px 0px #090909" );

23
24 //Compass output"
25 // >>> Change detected at 20:56:35 to: superman_gif.scss
26 // ~/path/to/file/sass/style.scss:36 DEBUG: ____ PASS ____ adjust converts number of blocks into pixel equivaent
27 // ~/path/to/file/sass/style.scss:42 DEBUG: ____ PASS ____ draw_pixel creates box-shadow based off of $width
28 // ~/path/to/file/sass/style.scss:45 DEBUG: ____ PASS ____ draw_pixel creates a number of box-shadow css output equal to the length
29 // ~/path/to/file/sass/style.scss:: ____ PASS ____ function DRAW_LINE: creates box-shadow based off of $width
30 // ~/path/to/file/sass/style.scss:59 DEBUG: ____ PASS ____ draw_line creates a number of box-shadow css output equal to the length
31 // ~/path/to/file/sass/style.scss:81 DEBUG: ____ FAIL ____ draw_row draws a pixel for each block ____ Expected 30px 0px #090909,36px 0px #090909,42px 0px #f5d858,48px 0px #090909,54px 0px #090909 to equal EXPECTATION: 30px 0px #090909,36px 0px #090909,42px 0px #f5d858,48px 0px #0s90909,54px 0px #090909 32

33 // Or broken up to be increase readability

34 // template

35

36 $state: "" ;
37 $assert: "" ;
38 $expect: "" ;

39

40 @debug test( $state , $assert , $expect );

41

42 // usage

43

44 $state: "draw_row draws a pixel for each block" ;
45 $assert: draw_row(4, $lengths : (2,1,2), $colors : ( $hair , $crown-gold , $hair ));
46 $expect: "30px 0px #090909,36px 0px #090909,42px 0px #f5d858,48px 0px #090909,54px 0px #090909" ;

47

48 @debug test( $state , $assert , $expect );