Last active
January 3, 2016 01:29
-
-
Save jamiebuilds/8389567 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
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
// ---- | |
// Sass (v3.3.0.rc.2) | |
// Compass (v1.0.0.alpha.17) | |
// ---- | |
@function to-json($input) { | |
$output: ""; | |
$type: type-of($input); | |
$length: length($input); | |
$i: 1; | |
@if $type == list { | |
$output: "[ "; | |
@each $item in $input { | |
$item: to-json($item); | |
$output: $output + $item; | |
@if ($i != $length) { | |
$output: $output + ", "; | |
} | |
$i: $i + 1; | |
} | |
$output: $output + " ]"; | |
} | |
@if $type == map { | |
$output: "{ "; | |
@each $key, $value in $input { | |
$value: to-json($value); | |
$output: $output + '"' + $key + '"' + " : " + $value + ""; | |
@if ($i != $length) { | |
$output: $output + ", "; | |
} | |
$i: $i + 1; | |
} | |
$output: $output + " }"; | |
} | |
@if $type == number { | |
$output: $input; | |
} | |
@if $type == string { | |
$output: '"' + $input + '"'; | |
} | |
@if $type == bool { | |
$output: $input; | |
} | |
@return $output; | |
} | |
/* results = #{ to-json( (a: a, b: ( 1, false, ( a: 1, b: 2 ) ), c: 3) ) } */ |
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
/* results = { "a" : "a", "b" : [ 1, false, { "a" : 1, "b" : 2 } ], "c" : 3 } */ |
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
{ | |
"options" : [ | |
"verbose", | |
"warnings" | |
], | |
"tests" : [ | |
{ | |
"title" : "The positive number function should return all positive numbers", | |
"passed" : true, | |
"assertions" : [ | |
{ | |
"title" : "expected 1 to be a positive number", | |
"passed" : true | |
}, | |
{ | |
"title" : "expected 2 to be a positive number", | |
"passed" : true | |
}, | |
{ | |
"title" : "expected 3 to be a positive number", | |
"passed" : true | |
} | |
] | |
}, | |
{ | |
"title" : "The positive number function should return false for zero", | |
"passed" : false, | |
"assertions" : [ | |
{ | |
"title" : "expected 0 to equal false", | |
"passed" : false | |
} | |
] | |
}, | |
{ | |
"title" : "The positive number function should return false for all negative numbers", | |
"passed" : true, | |
"assertions" : [ | |
{ | |
"title" : "expected false not to be true", | |
"passed" : true | |
}, | |
{ | |
"title" : "expected false not to be true", | |
"passed" : true | |
}, | |
{ | |
"title" : "expected false not to be true", | |
"passed" : true | |
} | |
] | |
} | |
], | |
"results" : { | |
"stats" : "✔ ✔ ✔ ✗ ✔ ✔ ✔", | |
"assertions" : 7, | |
"tests" : 3, | |
"passed" : 2, | |
"failed" : 1 | |
}, | |
"warnings" : [ | |
{ | |
"title" : "The 'equal' matcher should only be used for numbers, try 'be' instead.", | |
"instances" : [ | |
"The positive number function should return false for zero: expected 0 to equal false" | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment