Skip to content

Commit

Permalink
Merge pull request #103 from mohayonao/dev
Browse files Browse the repository at this point in the history
update dev tools
  • Loading branch information
mohayonao committed Jul 3, 2014
2 parents 3cf12a8 + d55375b commit 86b8651
Show file tree
Hide file tree
Showing 42 changed files with 2,013 additions and 2,575 deletions.
80 changes: 40 additions & 40 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,6 @@ module.exports = function(grunt) {

var _ = require("underscore");

grunt._loadNpmTasksIfNeeded = function(name) {
if (!grunt._loadNpmTasksIfNeeded[name]) {
grunt._loadNpmTasksIfNeeded[name] = true;
grunt.loadNpmTasks(name);
}
};

grunt.file._expand = function() {
var dict = grunt.file.readJSON("tools/grunt-tasks/assets/files.json");
var list = grunt.file.expand(_.chain(arguments).map(function(name) {
return dict[name] || name;
}).flatten().value());

Object.defineProperty(list, "applyFilter", {
value: function(filter) {
return applyFilter(this, filter);
}
});

return list;
};

var applyFilter = function(list, filter) {
return !filter ? list : _.chain(filter.split("+")).map(function(filter) {
return _.chain(list).filter(function(file) {
return file.indexOf(filter) !== -1;
}).value();
}).flatten().value();
};

var toTaskArgs = function(args) {
if (_.isUndefined(args)) {
return "";
}
if (_.isArguments(args)) {
return _.map(args, toTaskArgs).join(":");
}
return args;
};

grunt.initConfig({
pkg: grunt.file.readJSON("package.json")
});
Expand Down Expand Up @@ -128,4 +88,44 @@ module.exports = function(grunt) {
"build", "test::nyan:lcov", "plato"
]
);

grunt._loadNpmTasksIfNeeded = function(name) {
if (!grunt._loadNpmTasksIfNeeded[name]) {
grunt._loadNpmTasksIfNeeded[name] = true;
grunt.loadNpmTasks(name);
}
};

grunt.file._expand = function() {
var dict = grunt.file.readJSON("tools/grunt-tasks/assets/files.json");
var list = grunt.file.expand(_.chain(arguments).map(function(name) {
return dict[name] || name;
}).flatten().value());

Object.defineProperty(list, "applyFilter", {
value: function(filter) {
return applyFilter(this, filter);
}
});

return list;
};

function applyFilter(list, filter) {
return !filter ? list : _.chain(filter.split("+")).map(function(filter) {
return _.chain(list).filter(function(file) {
return file.indexOf(filter) !== -1;
}).value();
}).flatten().value();
}

function toTaskArgs(args) {
if (_.isUndefined(args)) {
return "";
}
if (_.isArguments(args)) {
return _.map(args, toTaskArgs).join(":");
}
return args;
}
};
32 changes: 16 additions & 16 deletions demo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ window.onload = function() {
};
}

var update = function(source) {
function update(source) {
if (prev !== source) {
window.location.replace("#" + encodeURIComponent(source));
prev = source;
}
};
}

var getCode = function(editor) {
function getCode(editor) {
var code, cursor, line, range, callback;
var cssName = "blink1";

Expand All @@ -43,9 +43,9 @@ window.onload = function() {
blink(cssName, ".CodeMirror-focused .CodeMirror-selected", callback);

return code;
};
}

var selectRegion = function(editor, begin) {
function selectRegion(editor, begin) {
var lookAt, end, last, line;
var depth, code;

Expand Down Expand Up @@ -81,7 +81,7 @@ window.onload = function() {
lookAt = end;
}
}
};
}

var getCssRule = (function() {
var cache = {};
Expand All @@ -100,7 +100,7 @@ window.onload = function() {
};
})();

var blink = function(cssName, selector, callback) {
function blink(cssName, selector, callback) {
var rule = getCssRule(selector);
if (rule) {
setTimeout(function() {
Expand All @@ -111,9 +111,9 @@ window.onload = function() {
}, 500);
rule.style.setProperty("-webkit-animation", cssName + " 0.5s");
}
};
}

var evaluate = function() {
function evaluate() {
var code, result;
var beginTime, elapsedTime;

Expand All @@ -138,17 +138,17 @@ window.onload = function() {
if (!isNaN(elapsedTime)) {
$("#timecop").text(elapsedTime.toFixed(3) + "ms");
}
};
}

var boot = function() {
function boot() {
console.log("boot");
};
}

var stop = function() {
function stop() {
console.log("stop");
};
}

var readFromGist = function(gistid, callback) {
function readFromGist(gistid, callback) {
var url = "https://api.github.com/gists/" + gistid;
$.ajax({ url: url, type: "GET", dataType: "jsonp" }).then(function(result) {
var files, code;
Expand All @@ -165,7 +165,7 @@ window.onload = function() {
}
callback(code);
});
};
}

editor = CodeMirror.fromTextArea(document.getElementById("editor"), {
mode: "SCScript",
Expand Down
4 changes: 2 additions & 2 deletions demo/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ $(function() {
return escodegen.generate(esprima.parse(code), { indent: " " });
}

var update = function(code, mode) {
function update(code, mode) {
while (/^\([\s\S]+\)$/.test(code)) {
code = code.slice(1, -1);
}
Expand All @@ -37,7 +37,7 @@ $(function() {
}
prev = [ code, mode ];
}
};
}

$("#selector a").each(function(i, elem) {
$(elem).on("click", function() {
Expand Down
74 changes: 32 additions & 42 deletions src/sc/classlib/Collections/Array_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
var testCase = sc.test.testCase;

var $ = sc.lang.$;

var SCArray = $("Array");

describe("SCArray", function() {
Expand All @@ -25,7 +24,9 @@
expect(test).to.be.a("JSArray").to.eql([ "freq", 440 ]);
});
it(".with", function() {
var test = SCArray.with($$(0), $$(1), $$(2));
var test;

test = SCArray.with($$(0), $$(1), $$(2));
expect(test).to.be.a("SCArray").that.eqls([ 0, 1, 2 ]);
});
it("#reverse", function() {
Expand Down Expand Up @@ -692,63 +693,56 @@
});
it("#asUGenInput", sinon.test(function() {
var instance, test;
var $elem1, $elem2, $elem3;
var $ugen1, $ugen2, $ugen3;
var $for;

$elem1 = $$({
var $elem1 = $$({
asUGenInput: this.spy(function() {
return $ugen1;
})
});
$elem2 = $$({
var $elem2 = $$({
asUGenInput: this.spy(function() {
return $ugen2;
})
});
$elem3 = $$({
var $elem3 = $$({
asUGenInput: this.spy(function() {
return $ugen3;
})
});
$ugen1 = $$();
$ugen2 = $$();
$ugen3 = $$();
$for = $$();
var $ugen1 = $$();
var $ugen2 = $$();
var $ugen3 = $$();
var $for = $$();

instance = this.createInstance([ $elem1, $elem2, $elem3 ]);

test = instance.asUGenInput($for);
expect($elem1.asUGenInput).to.be.calledWith($for);
expect($elem2.asUGenInput).to.be.calledWith($for);
expect($elem3.asUGenInput).to.be.calledWith($for);
expect($elem1.asUGenInput, 1).to.be.calledWith($for);
expect($elem2.asUGenInput, 2).to.be.calledWith($for);
expect($elem3.asUGenInput, 3).to.be.calledWith($for);
expect(test).to.be.a("SCArray").that.eqls([ $ugen1, $ugen2, $ugen3 ]);
}));
it("#asAudioRateInput", sinon.test(function() {
var instance, test;
var $elem1, $elem2, $elem3;
var $ugen1, $ugen2, $ugen3;
var $for;

$elem1 = $$({
var $elem1 = $$({
asAudioRateInput: this.spy(function() {
return $ugen1;
})
});
$elem2 = $$({
var $elem2 = $$({
asAudioRateInput: this.spy(function() {
return $ugen2;
})
});
$elem3 = $$({
var $elem3 = $$({
asAudioRateInput: this.spy(function() {
return $ugen3;
})
});
$ugen1 = $$();
$ugen2 = $$();
$ugen3 = $$();
$for = $$();
var $ugen1 = $$();
var $ugen2 = $$();
var $ugen3 = $$();
var $for = $$();

instance = this.createInstance([ $elem1, $elem2, $elem3 ]);

Expand All @@ -760,27 +754,24 @@
}));
it("#asControlInput", sinon.test(function() {
var instance, test;
var $elem1, $elem2, $elem3;
var $ugen1, $ugen2, $ugen3;

$elem1 = $$({
var $elem1 = $$({
asControlInput: this.spy(function() {
return $ugen1;
})
});
$elem2 = $$({
var $elem2 = $$({
asControlInput: this.spy(function() {
return $ugen2;
})
});
$elem3 = $$({
var $elem3 = $$({
asControlInput: this.spy(function() {
return $ugen3;
})
});
$ugen1 = $$();
$ugen2 = $$();
$ugen3 = $$();
var $ugen1 = $$();
var $ugen2 = $$();
var $ugen3 = $$();

instance = this.createInstance([ $elem1, $elem2, $elem3 ]);

Expand All @@ -794,6 +785,7 @@
var instance, test;

instance = this.createInstance();

test = instance.isValidUGenInput();
expect(test).to.be.a("SCBoolean").that.equals(true);
});
Expand Down Expand Up @@ -821,19 +813,17 @@
it.skip("#fork", function() {
});
it("#madd", sinon.test(function() {
var instance, test, spy;
var $mul, $add;
var instance, test;
var spy = this.spy(sc.test.func());
var $mul = $$();
var $add = $$();

spy = this.spy(sc.test.func());
$mul = $$();
$add = $$();
instance = this.createInstance();
this.stub(sc.lang.klass, "get").withArgs("MulAdd").returns($$({
new: spy
}));

instance = this.createInstance();
test = instance.madd($mul, $add);

expect(spy).to.be.calledWith(instance, $mul, $add);
expect(spy).to.be.calledLastIn(test);
}));
Expand Down
Loading

0 comments on commit 86b8651

Please sign in to comment.