Created
February 16, 2014 05:01
-
-
Save TalkativeTree/9029558 to your computer and use it in GitHub Desktop.
Useful test function to test complicated Sass functions.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@function test($statement, $assertion, $expectation) { | |
@if $assertion != $expectation { | |
$result: "FAIL"; | |
@return "____ #{$result} ____ " + $statement + " ____ Expected #{$assertion} to equal EXPECTATION: #{$expectation}"; | |
} | |
@if $assertion == $expectation { | |
$result: "PASS"; | |
@return "____ #{$result} ____ " + $statement; | |
} | |
} | |
// example usage | |
@debug test("draw_pixel creates box-shadow based off of $width", draw_pixel(1, $hair),"6px 0px #090909"); | |
@debug test("draw_pixel creates a number of box-shadow css output equal to the length", draw_pixel(3, $hair),"18px 0px #090909"); | |
@debug test("function DRAW_LINE: creates box-shadow based off of $width", draw_line(0, 1, $hair), "6px 0px #090909"); | |
@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"); | |
@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"); | |
//Compass output | |
// >>> Change detected at 20:56:35 to: superman_gif.scss | |
// /Users/benjaminangel/programming/personal_apps/talkativetree/views/sass/superman_gif.scss:36 DEBUG: ____ PASS ____ adjust converts number of blocks into pixel equivaent | |
// /Users/benjaminangel/programming/personal_apps/talkativetree/views/sass/superman_gif.scss:42 DEBUG: ____ PASS ____ draw_pixel creates box-shadow based off of $width | |
// /Users/benjaminangel/programming/personal_apps/talkativetree/views/sass/superman_gif.scss:45 DEBUG: ____ PASS ____ draw_pixel creates a number of box-shadow css output equal to the length | |
// /Users/benjaminangel/programming/personal_apps/talkativetree/views/sass/superman_gif.scss:57 DEBUG: ____ PASS ____ function DRAW_LINE: creates box-shadow based off of $width | |
// /Users/benjaminangel/programming/personal_apps/talkativetree/views/sass/superman_gif.scss:59 DEBUG: ____ PASS ____ draw_line creates a number of box-shadow css output equal to the length | |
// /Users/benjaminangel/programming/personal_apps/talkativetree/views/sass/superman_gif.scss:81 DEBUG: ____ PASS ____ draw_row draws a pixel for each block | |
// or broken up to be more readable | |
//template | |
$state: ""; | |
$assert: ""; | |
$expect: ""; | |
@debug test($state, $assert, $expect); | |
// usage | |
$state: "draw_row draws a pixel for each block"; | |
$assert: draw_row(4, $lengths: (2,1,2), $colors: ($hair, $crown-gold, $hair)); | |
$expect: "30px 0px #090909,36px 0px #090909,42px 0px #f5d858,48px 0px #090909,54px 0px #090909"; | |
@debug test($state, $assert, $expect); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment