Skip to content

Instantly share code, notes, and snippets.

@mirisuzanne
Last active August 29, 2015 14:08
Show Gist options
  • Select an option

  • Save mirisuzanne/5b041e1c23fd045ca56c to your computer and use it in GitHub Desktop.

Select an option

Save mirisuzanne/5b041e1c23fd045ca56c to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// libsass (v3.0)
// ----
// Like yep/nope for Sass,
// but it only works on the latest releases... :P
$yep: 'yep';
$nope: 'nope';
$meh: 'not really';
@function yepnope($feature) {
@if function-exists(yn--#{$feature}) {
@return call(yn--#{$feature});
} @else {
@warn "There is no test for that feature.";
}
}
@function yn--map-get() {
@if function-exists(map-get) {
$map: (foo: bar, baz: bing);
@if map-get($map, foo) == bar {
@return $yep;
}
@return $meh;
}
@return $nope;
}
@function yn--map-remove() {
@if function-exists(map-remove) {
$map1: (foo: bar, baz: bing);
$map2: (baz: bing);
@if map-remove($map1, foo) == $map2 {
@return $yep;
}
@return $meh;
}
@return $nope;
}
@function yn--map-merge() {
@if function-exists(map-merge) {
$map1: (foo: bar, baz: bing);
$map2: (foo: pow, hello: world);
$map3: (foo: pow, baz: bing, hello: world);
@if map-merge($map1, $map2) == $map3 {
@return $yep;
}
@return $meh;
}
@return $nope;
}
@function yn--map-keys() {
@if function-exists(map-keys) {
$map1: (foo: bar, baz: bing);
@if map-keys($map1) == foo, baz {
@return $yep;
}
@return $meh;
}
@return $nope;
}
@function yn--map-values() {
@if function-exists(map-values) {
$map1: (foo: bar, baz: bing);
@if map-keys($map1) == bar, bing {
@return $yep;
}
@return $meh;
}
@return $nope;
}
@function yn--map-has-key() {
@if function-exists(map-has-key) {
$map1: (foo: bar, baz: bing);
@if map-has-key($map1, foo) == true {
@return $yep;
}
@return $meh;
}
@return $nope;
}
@function yn--map-compare() {
$map1: (one: 1, two: 2);
@if $map1 == $map1 {
$map2: (one: (two: three), four: five);
$map3: (four: five, one: (two: three));
@if $map2 == $map3 {
@return $yep
}
@return $meh;
}
@return $nope;
}
.yepnope {
map-get: yepnope(map-get);
map-remove: yepnope(map-remove);
map-merge: yepnope(map-merge);
map-keys: yepnope(map-keys);
map-values: yepnope(map-values);
map-has-key: yepnope(map-has-key);
map-compare: yepnope(map-compare);
// it's hard to write tests for syntax changes
map-each: 'not really';
}
.yepnope {
map-get: 'yep';
map-remove: 'yep';
map-merge: 'not really';
map-keys: 'yep';
map-values: 'yep';
map-has-key: 'yep';
map-compare: 'not really';
map-each: 'not really'; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment