-
-
Notifications
You must be signed in to change notification settings - Fork 682
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added check for [bins] argument in fft method of P5, along with unit Test( in es6 style) #440
Draft
endurance21
wants to merge
6
commits into
processing:main
Choose a base branch
from
endurance21:FFT
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d6f356d
added feature of safeBins along with unit Test
endurance21 7167709
added feature of safeBins along with unit Test
endurance21 14cf56e
removed comments
endurance21 7338f51
improved unit tests of safeBins method
endurance21 7fdbbbd
Merge branch 'FFT' of github.com:endurance21/p5.js-sound into FFT
endurance21 2bc77a8
replaced console.log with console.warn
endurance21 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use strict'; | ||
|
||
define(['chai'],(chai)=>{ | ||
const safeBins = p5.prototype.safeBins; | ||
let expect = chai.expect; | ||
|
||
describe('safeBins', ()=>{ | ||
it('can handle negative input ',()=>{ | ||
let test =-Math.random()*2; | ||
expect(safeBins(test)).to.equal(1024); | ||
}); | ||
it('can handle value less than 16 ',()=>{ | ||
let test = 10; | ||
expect(safeBins(test)).to.equal(1024); | ||
}); | ||
it('can handle value greater than 1024',()=>{ | ||
let test = 1500; | ||
expect(safeBins(test)).to.equal(1024); | ||
}); | ||
it('can handle value other than power 2',()=>{ | ||
let test = 1500; | ||
expect(safeBins(test)).to.equal(1024); | ||
}); | ||
it('can handle value equal to 0',()=>{ | ||
let test = 0; | ||
expect(safeBins(test)).to.equal(1024); | ||
}); | ||
it('can handle strings',()=>{ | ||
let test = 'testString'; | ||
expect(safeBins(test)).to.equal(1024); | ||
endurance21 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}); | ||
|
||
}); | ||
|
||
}); | ||
endurance21 marked this conversation as resolved.
Show resolved
Hide resolved
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to add this to the p5 prototype, or can this be a private method that is only used internally?
If it's only added to the prototype for the purpose of writing a test, I think the test should instead be on the public methods that utilize this function behind the scenes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@therewasaguy the main problem i face was using AMD here , I was unable to use safeBins defined in src/helper.js in test/tests/helpers.test.js , so I decided to put this method in prototype object of p5 ,
and I am realising now , that it is not the good way of doing it !,
so I will add tests on public function that will wrap this function ! and remove it from p5.prototype