Skip to content
This repository has been archived by the owner on Sep 25, 2018. It is now read-only.

Commit

Permalink
Added HTML runner for basic tests; updated README to reflect that tes…
Browse files Browse the repository at this point in the history
…ts have been run successfully in all major browsers.
  • Loading branch information
jbeard4 committed Jan 12, 2012
1 parent 61812f7 commit c49592e
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ SCION takes many ideas from the SCXML standard. In particular, it reuses the syn

# Project Status and Supported Environments

SCION has been thoroughly tested in recent versions of Chromium, Firefox, and Opera on Ubuntu 10.04. It has *not* been thoroughly tested with older browsers, or on Internet Explorer or Safari. SCION has also been thoroughly tested under multiple shell environments, including Node and Rhino, as well as the shell environments included with v8, spidermonkey and jsc.
SCION has been thoroughly tested in recent versions of Chromium, Firefox, and Opera on Ubuntu 10.04, as well as Internet Explorer 9 and recent Firefox, Chrome, Opera, and Safari on Windows 7 x64. SCION has also been thoroughly tested under multiple shell environments, including Node and Rhino, as well as the default shell environments included with v8, spidermonkey and jsc.

# License

Expand Down
45 changes: 45 additions & 0 deletions bin/test-runner.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-->

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:svg="http://www.w3.org/2000/svg">
<head>
<script type="text/javascript" src="../lib/js/r.js"></script>

<script>
require(
{
baseUrl : "../build/core",
paths : {
"tests" : "../tests"
}
},
["scxml/test/basic-test-harness"],
function(fn){
if(typeof fn !== "function"){
console.error("Unable to find module");
return 1
}else{
return fn()
}
}
);
</script>
</head>
<body>
</body>
</html>
115 changes: 94 additions & 21 deletions lib/js/r.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @license r.js 1.0.3 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
* @license r.js 1.0.4 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
* Available via the MIT or new BSD license.
* see: http://github.com/jrburke/requirejs for details
*/
Expand All @@ -20,7 +20,7 @@ var requirejs, require, define;

var fileName, env, fs, vm, path, exec, rhinoContext, dir, nodeRequire,
nodeDefine, exists, reqMain, loadedOptimizedLib,
version = '1.0.3',
version = '1.0.4',
jsSuffixRegExp = /\.js$/,
commandOption = '',
//Used by jslib/rhino/args.js
Expand Down Expand Up @@ -98,6 +98,8 @@ var requirejs, require, define;
commandOption = fileName.substring(1);
fileName = process.argv[3];
}
} else if (typeof window !== "undefined" && navigator && document) {
env = 'browser';
} else if (typeof load === 'function' && typeof print === 'function'){
env = 'spartan';

Expand All @@ -119,10 +121,10 @@ var requirejs, require, define;
}
};
}
}
}

/** vim: et:ts=4:sw=4:sts=4
* @license RequireJS 1.0.3 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
* @license RequireJS 1.0.4 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
* Available via the MIT or new BSD license.
* see: http://github.com/jrburke/requirejs for details
*/
Expand All @@ -134,7 +136,7 @@ var requirejs, require, define;

(function () {
//Change this version number for each release.
var version = "1.0.3",
var version = "1.0.4",
commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
cjsRequireRegExp = /require\(\s*["']([^'"\s]+)["']\s*\)/g,
currDirRegExp = /^\.\//,
Expand Down Expand Up @@ -446,7 +448,15 @@ var requirejs, require, define;
url = urlMap[normalizedName];
if (!url) {
//Calculate url for the module, if it has a name.
url = context.nameToUrl(normalizedName, null, parentModuleMap);
//Use name here since nameToUrl also calls normalize,
//and for relative names that are outside the baseUrl
//this causes havoc. Was thinking of just removing
//parentModuleMap to avoid extra normalization, but
//normalize() still does a dot removal because of
//issue #142, so just pass in name here and redo
//the normalization. Paths outside baseUrl are just
//messy to support.
url = context.nameToUrl(name, null, parentModuleMap);

//Store the URL mapping for later.
urlMap[normalizedName] = url;
Expand Down Expand Up @@ -751,7 +761,7 @@ var requirejs, require, define;
prefix = map.prefix,
plugin = prefix ? plugins[prefix] ||
(plugins[prefix] = defined[prefix]) : null,
manager, created, pluginManager;
manager, created, pluginManager, prefixMap;

if (fullName) {
manager = managerCallbacks[fullName];
Expand Down Expand Up @@ -789,7 +799,18 @@ var requirejs, require, define;
//If there is a plugin needed, but it is not loaded,
//first load the plugin, then continue on.
if (prefix && !plugin) {
pluginManager = getManager(makeModuleMap(prefix), true);
prefixMap = makeModuleMap(prefix);

//Clear out defined and urlFetched if the plugin was previously
//loaded/defined, but not as full module (as in a build
//situation). However, only do this work if the plugin is in
//defined but does not have a module export value.
if (prefix in defined && !defined[prefix]) {
delete defined[prefix];
delete urlFetched[prefixMap.url];
}

pluginManager = getManager(prefixMap, true);
pluginManager.add(function (plugin) {
//Create a new manager for the normalized
//resource ID and have it call this manager when
Expand Down Expand Up @@ -1860,7 +1881,8 @@ var requirejs, require, define;
node = context && context.config && context.config.xhtml ?
document.createElementNS("http://www.w3.org/1999/xhtml", "html:script") :
document.createElement("script");
node.type = type || "text/javascript";
node.type = type || (context && context.config.scriptType) ||
"text/javascript";
node.charset = "utf-8";
//Use async so Gecko does not block on executing the script if something
//like a long-polling comet tag is being run first. Gecko likes
Expand Down Expand Up @@ -2367,6 +2389,11 @@ define('spartan/args', function () {

}

if(env === 'browser') {
define('browser/args', function(){return function(){};});

}

if(env === 'node') {
/**
* @license RequireJS Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
Expand Down Expand Up @@ -2420,6 +2447,12 @@ define('spartan/load', function () {

}

if(env === 'browser') {
//nothing to do here
define('browser/load', function(){return function(){};});

}

if(env === 'node') {
/**
* @license Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
Expand Down Expand Up @@ -2999,6 +3032,11 @@ define('spartan/file', {
});


}

if(env === 'browser') {
define('browser/file', function(){return function(){};});

}
/**
* @license Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
Expand Down Expand Up @@ -3096,6 +3134,16 @@ define('spartan/print', function () {
return print;
});

}

if(env === 'browser') {
define('browser/print', function(){
return function(){
console.log.apply(console,Array.prototype.slice.apply(arguments));
};
});


}

if(env === 'node') {
Expand All @@ -3118,6 +3166,11 @@ define('spartan/quit', function(){
return quit;
});

}

if(env === 'browser') {
define('browser/quit', function(){return function(){};});

}
/**
* @license RequireJS Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
Expand Down Expand Up @@ -7594,6 +7647,11 @@ if(env === 'spartan') {

define('spartan/optimize', {});

}

if(env === 'browser') {
define('browser/optimize', function(){return function(){};});

}
/**
* @license Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
Expand Down Expand Up @@ -7858,7 +7916,7 @@ function (lang, logger, envOptimize, file, parse,
logger.trace("Uglifying file: " + fileName);

try {
ast = parser.parse(fileContents, config);
ast = parser.parse(fileContents, config.strict_semicolons);
ast = processor.ast_mangle(ast, config);
ast = processor.ast_squeeze(ast, config);

Expand Down Expand Up @@ -8041,8 +8099,13 @@ function (file, pragma, parse) {
//and to make sure this file is first, so that define calls work.
//This situation mainly occurs when the build is done on top of the output
//of another build, where the first build may include require somewhere in it.
if (!layer.existingRequireUrl && parse.definesRequire(url, contents)) {
layer.existingRequireUrl = url;
try {
if (!layer.existingRequireUrl && parse.definesRequire(url, contents)) {
layer.existingRequireUrl = url;
}
} catch (e1) {
throw new Error('Parse error using UglifyJS ' +
'for file: ' + url + '\n' + e1);
}

if (moduleName in context.plugins) {
Expand All @@ -8059,12 +8122,17 @@ function (file, pragma, parse) {
//Parse out the require and define calls.
//Do this even for plugins in case they have their own
//dependencies that may be separate to how the pluginBuilder works.
if (!context.needFullExec[moduleName]) {
contents = parse(moduleName, url, contents, {
insertNeedsDefine: true,
has: context.config.has,
findNestedDependencies: context.config.findNestedDependencies
});
try {
if (!context.needFullExec[moduleName]) {
contents = parse(moduleName, url, contents, {
insertNeedsDefine: true,
has: context.config.has,
findNestedDependencies: context.config.findNestedDependencies
});
}
} catch (e2) {
throw new Error('Parse error using UglifyJS ' +
'for file: ' + url + '\n' + e2);
}

require._cachedFileContents[url] = contents;
Expand Down Expand Up @@ -8128,8 +8196,8 @@ function (file, pragma, parse) {
} else if (map.url && require._isSupportedBuildUrl(map.url)) {
//If the url has not been added to the layer yet, and it
//is from an actual file that was loaded, add it now.
url = normalizeUrlWithBase(context, map.fullName, map.url);
if (!layer.pathAdded[url] && layer.buildPathMap[fullName]) {
url = normalizeUrlWithBase(context, map.fullName, map.url);
//Remember the list of dependencies for this layer.
layer.buildFilePaths.push(url);
layer.pathAdded[url] = true;
Expand Down Expand Up @@ -8886,6 +8954,10 @@ function (lang, logger, file, parse, optimize, pragma,
throw new Error("ERROR: 'baseUrl' option missing.");
}

if (!config.out && !config.dir) {
throw new Error('Missing either an "out" or "dir" config value.');
}

if (config.out && !config.cssIn) {
//Just one file to optimize.

Expand Down Expand Up @@ -9397,15 +9469,16 @@ function (args, build) {
//Just run an app

//Load the bundled libraries for use in the app.
if (commandOption === 'lib') {
//browser loads libs by default
if (commandOption === 'lib' || env === 'browser') {
loadLib();
}

setBaseUrl(fileName);

if(env === 'spartan'){
load(fileName);
} else{
} else if (env !== 'browser'){
if (exists(fileName)) {
exec(readFile(fileName), fileName);
} else {
Expand Down

0 comments on commit c49592e

Please sign in to comment.