Skip to content

Commit

Permalink
WIP - working toward a fractional class
Browse files Browse the repository at this point in the history
  • Loading branch information
XiNNiW committed Jan 5, 2023
1 parent 3ad40bf commit dbfc8f7
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Lunacy
# NAME

Lunacy is an experimental port of the livecoding music language [Tidalcycles](http://tidalcycles.org/) to the lua programming language. This project follows in the footsteps of [vortex](https://github.com/tidalcycles/vortex) and [strudel](https://strudel.tidalcycles.org). For me the main purpose of this project is to learn about how to implement a livecoding language. It is not likely to be directly useful as a tool or instrument.
NAME is an experimental port of the livecoding music language [Tidalcycles](http://tidalcycles.org/) to the lua programming language. This project follows in the footsteps of [vortex](https://github.com/tidalcycles/vortex) and [strudel](https://strudel.tidalcycles.org). For me the main purpose of this project is to learn about how to implement a livecoding language. It is not likely to be directly useful as a tool or instrument.


2 changes: 1 addition & 1 deletion runTests.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

lua ./test/lunacy_test.lua
lua ./test/all_tests.lua
3 changes: 2 additions & 1 deletion src/fractional.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function Fraction:new (
)
local n = numerator or 0
local d = denominator or 1
if denominator == 0 then error("Fractional: divide by zero") end
local normalize = shouldNormalize or true
n = math.floor(n)
d = math.floor(d)
Expand Down Expand Up @@ -253,4 +254,4 @@ end

function Fraction:floor ()
return self:numerator()//self:denominator()
end
end
File renamed without changes.
6 changes: 4 additions & 2 deletions test/fractional_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ function TestFractional__create()
lu.assertEquals(f:denominator(), 2)
end

function TestFractional__create()
function CreateFraction(n,d) return Fraction:new(n,d) end

function TestFractional__new()
local f = Fraction:new()
lu.assertEquals(f:numerator(), 0)
lu.assertEquals(f:denominator(), 1)
Expand All @@ -30,7 +32,7 @@ function TestFractional__create()
f = Fraction:new(-4,-8)
lu.assertEquals(f:numerator(), 1)
lu.assertEquals(f:denominator(), 2)

lu.assertError(CreateFraction, 1, 0)
end

function TestFractional__add()
Expand Down

0 comments on commit dbfc8f7

Please sign in to comment.