This file contains 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
it('updates chapter position property to match audio player position', function () { | |
bppg.generatePage({book: BOOK_OBJECT, chapter: chapterObjInstance}); | |
chapterObjInstance.position = -1 // set the position to a nonzero value | |
var dom_ele = $('#audioSource').trigger('timeupdate'); | |
expect(chapterObjInstance.position).equal(0); | |
}); |
This file contains 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
// FAILING TEST | |
describe('#test', function () { | |
it('tests args', function () { | |
storageMock.expects('test').once().withExactArgs(1234); | |
storageManager.otherFunctionThatCallsTest(chapter_obj.id); // should call #test with args: 1234 | |
storageMock.verify(); | |
}); | |
}); | |
/* Console Output: | |
* Unexpected call: test(1234) |
This file contains 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
describe('#generatePage()', function () { | |
it('generates download book button that sends #downloadBook to downloadManager object when clicked', function () { | |
// ... | |
}); | |
}); |
This file contains 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
LDX #$00 ; load #00 into x | |
LDY #$01 | |
loop: | |
INX ; increment X | |
STX $0200 ; draw a pixel of color x to screen at top left corner | |
BCS done | |
BNE loop ; any way to loop without checking anything? | |
done: | |
BRK |
This file contains 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
describe('BookPlayerPageGenerator()', function () { | |
var bppg, dlManager, dlManagerMock; | |
before(function () { | |
// ... (omitted) set up audio and button elements and append them to body ... | |
// Set up a dummy object with a stubbed BookDownloadManager interface | |
dlManager = { downloadBook: function (book_id, chapter_obj) {}, | |
downloadChapter: function (book_obj) {} }; | |
This file contains 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 Foo(args) { | |
var private_variable = args.private_var; | |
this.public_variable = args.public_var; | |
this.public_method = function () { }; | |
function private_method() { } | |
} |
This file contains 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
%w[a b c d].permutation.first(5).each {|i| p i} #=> same output as permutations_lazy1.rb |
This file contains 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
def permutations_lazy(list) | |
# return [list] if list.size == 1 | |
en = Enumerator.new do |y| | |
if list.size == 1 | |
# yield a new array with the list as its only element (instead of returning) | |
y.yield [list] | |
end | |
list.each do |locked| | |
puts "locking #{locked}" |
This file contains 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
def permutations_lazy(list) | |
# return [list] if list.size == 1 | |
en = Enumerator.new do |y| | |
if list.size == 1 | |
# yield instead of returning in the base case of recursion | |
y.yield list | |
end | |
list.each do |locked| | |
puts "locking #{locked}" |
This file contains 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
def permutations_lazy(list) | |
# recursion's base case: return, not yield (outside of enumerator) | |
return [list] if list.size == 1 | |
en = Enumerator.new do |y| | |
list.each do |locked| | |
puts "locking #{locked}" | |
list_copy = list.dup | |
list_copy.delete locked | |
permutations_lazy(list_copy).each do |permutation| | |
puts "permutation #{permutation}, locked #{locked}" |