Created
April 21, 2015 18:30
-
-
Save bensu/49d9a91316392c42269f to your computer and use it in GitHub Desktop.
Minimal PASSING case
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
var goog = goog || {}; | |
goog.typeOf = function(value) { | |
var s = typeof value; | |
if (s == "object") { | |
if (value) { | |
if (value instanceof Array) { | |
return "array"; | |
} else { | |
if (value instanceof Object) { | |
return s; | |
} | |
} | |
var className = Object.prototype.toString.call((value)); | |
if (className == "[object Window]") { | |
return "object"; | |
} | |
if (className == "[object Array]" || typeof value.length == "number" && typeof value.splice != "undefined" && typeof value.propertyIsEnumerable != "undefined" && !value.propertyIsEnumerable("splice")) { | |
return "array"; | |
} | |
if (className == "[object Function]" || typeof value.call != "undefined" && typeof value.propertyIsEnumerable != "undefined" && !value.propertyIsEnumerable("call")) { | |
return "function"; | |
} | |
} else { | |
return "null"; | |
} | |
} else { | |
if (s == "function" && typeof value.call == "undefined") { | |
return "object"; | |
} | |
} | |
return s; | |
}; | |
// Utilities | |
var cljs = {}; | |
cljs.core = {}; | |
cljs.core.missing_protocol = function cljs$core$missing_protocol(proto, obj) { | |
return new Error(["No protocol method ", proto, " defined for: ", obj].join("")); | |
}; | |
// Deref | |
cljs.core._deref = function cljs$core$_deref(o) { | |
if (function() { | |
var and__3880__auto__ = o; | |
if (and__3880__auto__) { | |
return o.cljs$core$IDeref$_deref$arity$1; | |
} else { | |
return and__3880__auto__; | |
} | |
}()) { | |
return o.cljs$core$IDeref$_deref$arity$1(o); | |
} else { | |
var x__4528__auto__ = o == null ? null : o; | |
return function() { | |
var or__3892__auto__ = cljs.core._deref[function() { | |
var G__6130 = x__4528__auto__; | |
return goog.typeOf(G__6130); | |
}()]; | |
if (or__3892__auto__) { | |
return or__3892__auto__; | |
} else { | |
var or__3892__auto____$1 = cljs.core._deref["_"]; | |
if (or__3892__auto____$1) { | |
return or__3892__auto____$1; | |
} else { | |
throw cljs.core.missing_protocol("IDeref.-deref", o); | |
} | |
} | |
}().call(null, o); | |
} | |
}; | |
// Volatile | |
cljs.core.Volatile = function(state) { | |
this.state = state; | |
this.cljs$lang$protocol_mask$partition0$ = 32768; | |
this.cljs$lang$protocol_mask$partition1$ = 0; | |
}; | |
cljs.core.Volatile.prototype.cljs$core$IDeref$_deref$arity$1 = function(_) { | |
var self__ = this; | |
var ___$1 = this; | |
return self__.state; | |
}; | |
cljs.core.volatile_BANG_ = function cljs$core$volatile_BANG_(val) { | |
return new cljs.core.Volatile(val); | |
}; | |
// MyCustomAtom | |
cljs.core_test = {}; | |
cljs.core_test.MyCustomAtom = function(state) { | |
this.state = state; | |
this.cljs$lang$protocol_mask$partition0$ = 32768; | |
this.cljs$lang$protocol_mask$partition1$ = 0; | |
}; | |
cljs.core_test.MyCustomAtom.prototype.cljs$core$IDeref$_deref$arity$1 = function(_) { | |
var self__ = this; | |
var ___$1 = this; | |
return self__.state; | |
}; | |
// Tests | |
cljs.core_test.test_919_generic_cas = {}; | |
cljs.core_test.test_919_generic_cas.cljs$lang$test = function() { | |
var ret__6026__auto__ = function() { | |
var a0 = new cljs.core_test.MyCustomAtom(10); | |
try { | |
var values__5968__auto__ = cljs.core._deref.call(null, a0); | |
return values__5968__auto__; | |
} catch (e6167) { | |
return e6167; | |
} | |
}(); | |
return ret__6026__auto__; | |
}; | |
cljs.core_test.test_atoms_and_volatile = {}; | |
cljs.core_test.test_atoms_and_volatile.cljs$lang$test = function() { | |
var v = cljs.core.volatile_BANG_.call(null, 1); | |
var ret__6026__auto__ = function() { | |
try { | |
var values__5968__auto__ = cljs.core._deref.call(null, v); | |
return values__5968__auto__; | |
} catch (e6167) { | |
return e6167; | |
} | |
}(); | |
return ret__6026__auto__; | |
}; | |
print(cljs.core_test.test_919_generic_cas.cljs$lang$test()); | |
print(cljs.core_test.test_atoms_and_volatile.cljs$lang$test()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment