Detect global object properly when getting the jasmine require obj

- Pull global detection into requireCore and pass the global to base

Fix #569
[fix #73684570]
This commit is contained in:
slackersoft
2014-08-28 13:28:55 -07:00
parent 18eb6e2f36
commit 3b8326f1e6
3 changed files with 270 additions and 266 deletions

View File

@@ -20,19 +20,24 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
function getJasmineRequireObj() { getJasmineRequireObj = (function (jasmineGlobal) {
if (typeof module !== 'undefined' && module.exports) { var jasmineRequire;
return exports;
} else {
window.jasmineRequire = window.jasmineRequire || {};
return window.jasmineRequire;
}
}
getJasmineRequireObj().core = function(jRequire) { if (typeof module !== 'undefined' && module.exports) {
jasmineGlobal = global;
jasmineRequire = exports;
} else {
jasmineRequire = jasmineGlobal.jasmineRequire = jasmineGlobal.jasmineRequire || {};
}
function getJasmineRequire() {
return jasmineRequire;
}
getJasmineRequire().core = function(jRequire) {
var j$ = {}; var j$ = {};
jRequire.base(j$); jRequire.base(j$, jasmineGlobal);
j$.util = jRequire.util(); j$.util = jRequire.util();
j$.Any = jRequire.Any(); j$.Any = jRequire.Any();
j$.CallTracker = jRequire.CallTracker(); j$.CallTracker = jRequire.CallTracker();
@@ -58,7 +63,10 @@ getJasmineRequireObj().core = function(jRequire) {
j$.matchers = jRequire.requireMatchers(jRequire, j$); j$.matchers = jRequire.requireMatchers(jRequire, j$);
return j$; return j$;
}; };
return getJasmineRequire;
})(this);
getJasmineRequireObj().requireMatchers = function(jRequire, j$) { getJasmineRequireObj().requireMatchers = function(jRequire, j$) {
var availableMatchers = [ var availableMatchers = [
@@ -90,12 +98,7 @@ getJasmineRequireObj().requireMatchers = function(jRequire, j$) {
return matchers; return matchers;
}; };
getJasmineRequireObj().base = (function (jasmineGlobal) { getJasmineRequireObj().base = function(j$, jasmineGlobal) {
if (typeof module !== 'undefined' && module.exports) {
jasmineGlobal = global;
}
return function(j$) {
j$.unimplementedMethod_ = function() { j$.unimplementedMethod_ = function() {
throw new Error('unimplemented method'); throw new Error('unimplemented method');
}; };
@@ -190,8 +193,7 @@ getJasmineRequireObj().base = (function (jasmineGlobal) {
} }
return obj; return obj;
}; };
}; };
})(this);
getJasmineRequireObj().util = function() { getJasmineRequireObj().util = function() {

View File

@@ -1,9 +1,4 @@
getJasmineRequireObj().base = (function (jasmineGlobal) { getJasmineRequireObj().base = function(j$, jasmineGlobal) {
if (typeof module !== 'undefined' && module.exports) {
jasmineGlobal = global;
}
return function(j$) {
j$.unimplementedMethod_ = function() { j$.unimplementedMethod_ = function() {
throw new Error('unimplemented method'); throw new Error('unimplemented method');
}; };
@@ -98,5 +93,4 @@ getJasmineRequireObj().base = (function (jasmineGlobal) {
} }
return obj; return obj;
}; };
}; };
})(this);

View File

@@ -1,16 +1,21 @@
function getJasmineRequireObj() { getJasmineRequireObj = (function (jasmineGlobal) {
if (typeof module !== 'undefined' && module.exports) { var jasmineRequire;
return exports;
} else {
window.jasmineRequire = window.jasmineRequire || {};
return window.jasmineRequire;
}
}
getJasmineRequireObj().core = function(jRequire) { if (typeof module !== 'undefined' && module.exports) {
jasmineGlobal = global;
jasmineRequire = exports;
} else {
jasmineRequire = jasmineGlobal.jasmineRequire = jasmineGlobal.jasmineRequire || {};
}
function getJasmineRequire() {
return jasmineRequire;
}
getJasmineRequire().core = function(jRequire) {
var j$ = {}; var j$ = {};
jRequire.base(j$); jRequire.base(j$, jasmineGlobal);
j$.util = jRequire.util(); j$.util = jRequire.util();
j$.Any = jRequire.Any(); j$.Any = jRequire.Any();
j$.CallTracker = jRequire.CallTracker(); j$.CallTracker = jRequire.CallTracker();
@@ -36,4 +41,7 @@ getJasmineRequireObj().core = function(jRequire) {
j$.matchers = jRequire.requireMatchers(jRequire, j$); j$.matchers = jRequire.requireMatchers(jRequire, j$);
return j$; return j$;
}; };
return getJasmineRequire;
})(this);