-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
range()
to generate sequences for a given number range
- Loading branch information
Showing
4 changed files
with
52 additions
and
2 deletions.
There are no files selected for viewing
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,22 @@ | ||
import {range} from "../src/Sequence"; | ||
|
||
describe("range", () => { | ||
it("should create range of numbers with step = 1", () => { | ||
const numbers = range(0, 5).toArray(); | ||
expect(numbers).toEqual([0, 1, 2, 3, 4]); | ||
}); | ||
|
||
it("should create range of numbers with step = .5", () => { | ||
const numbers = range(0, 4, .5).toArray(); | ||
expect(numbers).toEqual([0, .5, 1, 1.5, 2, 2.5, 3, 3.5]); | ||
}); | ||
|
||
it("should create empty sequence", () => { | ||
const numbers = range(0, 1).toArray(); | ||
expect(numbers).toEqual([]); | ||
}); | ||
|
||
it("should throw on invalid boundaries", () => { | ||
expect(() => range(1, 0)).toThrow(); | ||
}); | ||
}); |