Skip to content
Permalink
Browse files

test: split tests

  • Loading branch information...
kou committed Mar 10, 2019
1 parent e8e6259 commit 668cea57cee7dd0fb8f311a17dd6644fa09395e6
Showing with 60 additions and 29 deletions.
  1. +60 −29 test/test-applier.rb
@@ -1,42 +1,73 @@
require 'fileutils'

require "rabbit-test-utils"
# Copyright (C) 2012-2019 Kouhei Sutou <kou@cozmixng.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

require "rabbit/theme/applier"

class RabbitApplierTest < Test::Unit::TestCase
def test_normalize_source
assert_normalize_source_ivar("x_large_font_size", "huge_font_size")
assert_normalize_source_ivar("xx_large_font_size", "very_huge_font_size")
assert_normalize_source_ivar("x_large_script_font_size",
"huge_script_font_size")
end

def normalize_source(src)
dummy = Object.new
def dummy.slides
def setup
theme = Object.new
def theme.slides
Object.new
end
Rabbit::Theme::Applier.new(dummy).__send__(:normalize_source, src)
@applier = Rabbit::Theme::Applier.new(theme)
end

def assert_normalize_source(expected, src)
_wrap_assertion do
assert_equal(expected, normalize_source(src))
sub_test_case("#normalize_source") do
def normalize_source(source)
@applier.__send__(:normalize_source, source)
end

data("x large",
["x_large_font_size", "huge_font_size"],
keep: true)
data("xx large",
["xx_large_font_size", "very_huge_font_size"],
keep: true)
data("x large script",
["x_large_script_font_size", "huge_script_font_size"],
keep: true)

def test_reference
after, before = data
assert_equal("@#{after}",
normalize_source("@#{before}"))
end

def test_reference_in_parentheses
after, before = data
assert_equal("(@#{after})",
normalize_source("(@#{before})"))
end

def test_reference_with_arguments_in_parentheses
after, before = data
assert_equal("(xxx, @#{after}, xxx)",
normalize_source("(xxx, @#{before}, xxx)"))
end

def test_assign_without_space
after, before = data
assert_equal("@#{after}=111",
normalize_source("@#{before}=111"))
end
end

def assert_normalize_source_ivar(after, before)
_wrap_assertion do
assert_normalize_source("@#{after}", "@#{before}")
assert_normalize_source("@#{after}=111",
"@#{before}=111")
assert_normalize_source("@#{after} = 111",
"@#{before} = 111")
assert_normalize_source("(@#{after})",
"(@#{before})")
assert_normalize_source("(xxx, @#{after}, xxx)",
"(xxx, @#{before}, xxx)")
def test_assign_with_space
after, before = data
assert_equal("@#{after} = 111",
normalize_source("@#{before} = 111"))
end
end
end

0 comments on commit 668cea5

Please sign in to comment.
You can’t perform that action at this time.