This file contains hidden or 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
| (function() { | |
| var namespaces = {}; | |
| function namespace(string) { | |
| var object = namespaces; | |
| var levels = string.split("."); | |
| if (!(levels[0] in object) && levels[0] in window) { |
This file contains hidden or 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
| TestCase("Private member", { | |
| "test of object which has private member": function() { | |
| var MyClass = function(value) { | |
| this.getValue = function() { | |
| return value; | |
| } | |
| }; | |
| var obj = new MyClass(5); |
This file contains hidden or 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
| TestCase("Extend", { | |
| "test of extended class in ECMA3Script": function() { | |
| var SuperClass = function() { | |
| this.value = "piyo"; | |
| }; | |
| SuperClass.prototype.value = undefined; | |
| SuperClass.prototype.func = function() { return "hoge"; } | |
| var SubClass = function() {}; |
This file contains hidden or 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
| TestCase("range", { | |
| "test of range": function() { | |
| function range() { | |
| var s, e, i, j; | |
| if (2 < arguments.length) { | |
| s = arguments[0]; | |
| e = arguments[1]; | |
| i = arguments[2]; | |
| if (0 === i) { | |
| throw new Error("step must be not zero."); |
This file contains hidden or 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
| FileUploadForm = function(form) { | |
| this.form = form; | |
| form.find("input[type=file]").change(this._handleFileInputChanged.bind(this)); | |
| this.changeCallback = $.Callbacks(); | |
| this.disposeCallback = $.Callbacks(); | |
| } | |
| FileUploadForm.prototype = { | |
| form: undefined, |
This file contains hidden or 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
| TestCase("Applicative style on jQuery Deferred", { | |
| setUp: function() { | |
| Function.prototype.$ = function() { | |
| return $.when.apply($, arguments) | |
| .then(this.bind(null)); | |
| }; | |
| Function.prototype.$$ = function(obj) { | |
| var f = this; | |
| return function() { | |
| return $.when.apply($, arguments) |
This file contains hidden or 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
| TestCase("usage.sinon", { | |
| 'test mock for constructor': sinon.test(function() { | |
| var obj = { | |
| hoge: function(id) { | |
| this.id = id | |
| } | |
| }; | |
| this.mock(obj) |
This file contains hidden or 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
| #include <stdio.h> | |
| int main(int argc, char** argv) { | |
| //関数定義の前に関数利用のコードがあるとコンパイルエラー. | |
| hoge(); | |
| } | |
| void hoge() { | |
| puts("hoge"); | |
| } |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>Bootstrap 101 Template</title> | |
| <meta name="viewport" content="width=device-width,initial-scale=1.0"> | |
| </head> | |
| <body> | |
| <form id="form"> | |
| Select file to add to database: <input type="file" name="file"> | |
| <button type="submit">put into db</button> |
This file contains hidden or 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
| TestCase("hoge", { | |
| 'test for native method': function() { | |
| var f = console.log; | |
| //f("hoge"); //Illegal Invocation | |
| f.bind(console)("hoge"); | |
| }, | |
| //Native method では Illegal Invocation Error と表示されるが、 | |
| //理屈は通常オブジェクトの場合と同じ | |
| 'test': function() { | |
| var obj = { |