「JS開発におけるTDDと自動テストツール利用の勘所 」より引用。
http://www.slideshare.net/KojiNakamura/jstdd
- notで否定のMatcherとなる
- expect(x).toEqual(y)
- expect(x).not.toEqual(y)
- expect(x).toBe(y)
| # 「JS開発におけるTDDと自動テストツール利用の勘所 」より引用。 | |
| # http://www.slideshare.net/KojiNakamura/jstdd | |
| it "should be async", -> | |
| # 非同期処理ブロックはruns()で定義される | |
| runs -> | |
| expect(true).toBeTruthy() | |
| # waits()で次のブロック実行を、指定したミリ秒間保留する |
| # 「JS開発におけるTDDと自動テストツール利用の勘所 」より引用。 | |
| # http://www.slideshare.net/KojiNakamura/jstdd | |
| it "should be called", -> | |
| obj = | |
| method: -> | |
| spyOn obj, "method" # spyOnメソッドでオブジェクトの特定メソッドをスパイ化 | |
| obj.method() | |
| expect(obj.method).toHaveBeenCalled() # spy用のMatcherが用意されている |
| # 「JS開発におけるTDDと自動テストツール利用の勘所 」より引用。 | |
| # http://www.slideshare.net/KojiNakamura/jstdd | |
| describe "Object", -> | |
| beforeEach -> | |
| object = new MyObject | |
| afterEach -> | |
| # do something... |
「JS開発におけるTDDと自動テストツール利用の勘所 」より引用。
http://www.slideshare.net/KojiNakamura/jstdd
| NSError *error = nil; | |
| NSRegularExpression *regexp = [NSRegularExpression regularExpressionWithPattern:@"\"http://.+\\.smilevideo\\.jp/smile\\?i=[0-9]{8}+\"" options:0 error:&error]; | |
| // エラーならば表示する | |
| if (error != nil) { | |
| NSLog(@"%@", error); | |
| } | |
| // find by regular expression | |
| NSTextCheckingResult *match = |
下記コードではtimerという関数をグローバルオブジェクト化している。
root = exports ? this
root.timer = window.setInterval(
->
dat = new Date()
document.getElementById('result').innerHTML = dat.toLocaleTimeString()
1000
)
まずCoffeeで下記のように書いて
root = exports ? this
root.foo = ->
alert 'Hello World'
return
HTMLから下記のように呼ぶ