Skip to content

Commit 9b6573b

Browse files
committed
.
1 parent 8a162b9 commit 9b6573b

File tree

9 files changed

+84
-24
lines changed

9 files changed

+84
-24
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# frozen_string_literal: true
2+
3+
require_relative "../test_helper"
4+
5+
module Sevgi
6+
module Graphics
7+
class GraphicsTest < Minitest::Test
8+
def test_svg_is_graphics
9+
assert(SVG.is_a?(::Module))
10+
assert_equal(SVG, Graphics)
11+
end
12+
13+
def test_graphics_interface
14+
%i[
15+
SVG
16+
canvas
17+
document
18+
paper
19+
paper!
20+
].each do
21+
assert_respond_to(Graphics, it)
22+
end
23+
end
24+
25+
def test_graphics_graphics_canvas
26+
canvas = Graphics.canvas(width: 3, height: 5)
27+
assert_instance_of(Graphics::Canvas, canvas)
28+
end
29+
30+
def test_graphics_graphics_doc
31+
doc = Graphics.document(:foo)
32+
assert(doc < Graphics::Document::Base)
33+
end
34+
35+
def test_graphics_graphics_paper
36+
paper = Graphics.paper(3, 5, :xyz)
37+
assert_equal(:xyz, paper)
38+
end
39+
40+
def test_graphics_graphics_paper_bang
41+
paper = Graphics.paper!(3, 5, :abc)
42+
assert_equal(:abc, paper)
43+
end
44+
end
45+
end
46+
end

toplevel/lib/sevgi/toplevel/graphics.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
module Sevgi
66
module Toplevel
7+
def Mixin(mod, document = Graphics::Document::Base, &block)
8+
document.mixture(mod)
9+
document.mixture(::Module.new(&block)) if block
10+
end
11+
712
promote Graphics, :SVG
813
end
914
end

toplevel/test/external/external_test.rb

Lines changed: 0 additions & 8 deletions
This file was deleted.

toplevel/test/external/graphics_test.rb

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
require_relative "../test_helper"
44

55
module Sevgi
6-
class ExternalDerenderTest < Minitest::Test
6+
class ToplevelDerenderTest < Minitest::Test
77
end
88
end
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
require_relative "../test_helper"
44

55
module Sevgi
6-
class ExternalFunctionTest < Minitest::Test
6+
class ToplevelFunctionTest < Minitest::Test
77
end
88
end
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
require_relative "../test_helper"
44

55
module Sevgi
6-
class ExternalGeometryTest < Minitest::Test
6+
class ToplevelGeometryTest < Minitest::Test
77
end
88
end
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# frozen_string_literal: true
2+
3+
require_relative "../test_helper"
4+
5+
module Sevgi
6+
class ToplevelGraphicsTest < Minitest::Test
7+
def test_toplevel_graphics_canvas
8+
assert(SVG.is_a?(::Module))
9+
assert_equal(SVG, Graphics)
10+
end
11+
12+
def test_toplevel_mixin
13+
klass = Class.new do
14+
include ::Sevgi
15+
end
16+
17+
obj = klass.new
18+
doc = Graphics.document(:mixin)
19+
20+
begin
21+
Sevgi::Graphics::Mixtures.const_set(:Foo, Module.new)
22+
obj.Mixin(:Foo, doc)
23+
assert_raises(NoMethodError) { Mixin(:Foo, doc) }
24+
ensure
25+
Sevgi::Graphics::Mixtures.send(:remove_const, :Foo)
26+
end
27+
end
28+
end
29+
end
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
require_relative "../test_helper"
44

55
module Sevgi
6-
class ExternalSundriesTest < Minitest::Test
6+
class ToplevelSundriesTest < Minitest::Test
77
end
88
end

0 commit comments

Comments
 (0)