Class: TestNotes

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
lib/tests.rb

Instance Method Summary collapse

Instance Method Details

#test_incObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/tests.rb', line 30

def test_inc
  Composer.scale = "major"
  n=Note.new(0,5)
  assert_equal([0, 2, 4, 5, 7, 9, 11], scale_notes)
  b=n.inc 2
  assert_equal 4, b.note
  b=n.inc 7
  assert_equal 0, b.note
  assert_equal 6, b.octave
  b=n.inc 0
  assert_equal 0, b.note
  assert_equal 5, b.octave
  b=n.inc -2
  assert_equal 9, b.note
  assert_equal 4, b.octave
  b=n.inc -9
  assert_equal 9, b.note
  assert_equal 3, b.octave
end

#test_opsObject



25
26
27
28
29
# File 'lib/tests.rb', line 25

def test_ops
  n=Note.new(1,5) + (-3)
  assert_equal(true, Note.new(10,4).is_eql(n))
  assert_equal(true, Note.new(3,5).is_eql(n+5))
end