Fix order of tests

This commit is contained in:
kojix2 2021-05-29 09:45:29 +09:00
parent 2005eaf871
commit 72f59887de
3 changed files with 55 additions and 50 deletions

View File

@ -15,8 +15,10 @@ module YouPlot
arr.value_counts(dropna: false) arr.value_counts(dropna: false)
end end
.sort do |a, b| .sort do |a, b|
r = b[1] <=> a[1] # compare values # compare values
r = a[0] <=> b[0] if r == 0 # If the values are the same, compare by name r = b[1] <=> a[1]
# If the values are the same, compare by name
r = a[0] <=> b[0] if r == 0
r r
end end
.transpose .transpose

View File

@ -34,19 +34,14 @@ class YouPlotIRISTest < Test::Unit::TestCase
File.read(File.expand_path("../fixtures/#{fname}", __dir__)) File.read(File.expand_path("../fixtures/#{fname}", __dir__))
end end
test :bar do
YouPlot::Command.new(['bar', '-H', '-d,', '-t', 'IRIS-BARPLOT']).run
assert_equal fixture('iris-barplot.txt'), @stderr_file.read
end
test :barplot do test :barplot do
YouPlot::Command.new(['barplot', '-H', '-d,', '-t', 'IRIS-BARPLOT']).run YouPlot::Command.new(['barplot', '-H', '-d,', '-t', 'IRIS-BARPLOT']).run
assert_equal fixture('iris-barplot.txt'), @stderr_file.read assert_equal fixture('iris-barplot.txt'), @stderr_file.read
end end
test :hist do test :bar do
YouPlot::Command.new(['hist', '-H', '-d,', '-t', 'IRIS-HISTOGRAM']).run YouPlot::Command.new(['bar', '-H', '-d,', '-t', 'IRIS-BARPLOT']).run
assert_equal fixture('iris-histogram.txt'), @stderr_file.read assert_equal fixture('iris-barplot.txt'), @stderr_file.read
end end
test :histogram do test :histogram do
@ -54,9 +49,9 @@ class YouPlotIRISTest < Test::Unit::TestCase
assert_equal fixture('iris-histogram.txt'), @stderr_file.read assert_equal fixture('iris-histogram.txt'), @stderr_file.read
end end
test :line do test :hist do
YouPlot::Command.new(['line', '-H', '-d,', '-t', 'IRIS-LINEPLOT']).run YouPlot::Command.new(['hist', '-H', '-d,', '-t', 'IRIS-HISTOGRAM']).run
assert_equal fixture('iris-lineplot.txt'), @stderr_file.read assert_equal fixture('iris-histogram.txt'), @stderr_file.read
end end
test :lineplot do test :lineplot do
@ -64,9 +59,9 @@ class YouPlotIRISTest < Test::Unit::TestCase
assert_equal fixture('iris-lineplot.txt'), @stderr_file.read assert_equal fixture('iris-lineplot.txt'), @stderr_file.read
end end
test :lines do test :line do
YouPlot::Command.new(['lines', '-H', '-d,', '-t', 'IRIS-LINEPLOTS']).run YouPlot::Command.new(['line', '-H', '-d,', '-t', 'IRIS-LINEPLOT']).run
assert_equal fixture('iris-lineplots.txt'), @stderr_file.read assert_equal fixture('iris-lineplot.txt'), @stderr_file.read
end end
test :lineplots do test :lineplots do
@ -74,9 +69,9 @@ class YouPlotIRISTest < Test::Unit::TestCase
assert_equal fixture('iris-lineplots.txt'), @stderr_file.read assert_equal fixture('iris-lineplots.txt'), @stderr_file.read
end end
test :s do test :lines do
YouPlot::Command.new(['s', '-H', '-d,', '-t', 'IRIS-SCATTER']).run YouPlot::Command.new(['lines', '-H', '-d,', '-t', 'IRIS-LINEPLOTS']).run
assert_equal fixture('iris-scatter.txt'), @stderr_file.read assert_equal fixture('iris-lineplots.txt'), @stderr_file.read
end end
test :scatter do test :scatter do
@ -84,9 +79,9 @@ class YouPlotIRISTest < Test::Unit::TestCase
assert_equal fixture('iris-scatter.txt'), @stderr_file.read assert_equal fixture('iris-scatter.txt'), @stderr_file.read
end end
test :d do test :s do
YouPlot::Command.new(['d', '-H', '-d,', '-t', 'IRIS-DENSITY']).run YouPlot::Command.new(['s', '-H', '-d,', '-t', 'IRIS-SCATTER']).run
assert_equal fixture('iris-density.txt'), @stderr_file.read assert_equal fixture('iris-scatter.txt'), @stderr_file.read
end end
test :density do test :density do
@ -94,9 +89,9 @@ class YouPlotIRISTest < Test::Unit::TestCase
assert_equal fixture('iris-density.txt'), @stderr_file.read assert_equal fixture('iris-density.txt'), @stderr_file.read
end end
test :box do test :d do
YouPlot::Command.new(['box', '-H', '-d,', '-t', 'IRIS-BOXPLOT']).run YouPlot::Command.new(['d', '-H', '-d,', '-t', 'IRIS-DENSITY']).run
assert_equal fixture('iris-boxplot.txt'), @stderr_file.read assert_equal fixture('iris-density.txt'), @stderr_file.read
end end
test :boxplot do test :boxplot do
@ -104,6 +99,11 @@ class YouPlotIRISTest < Test::Unit::TestCase
assert_equal fixture('iris-boxplot.txt'), @stderr_file.read assert_equal fixture('iris-boxplot.txt'), @stderr_file.read
end end
test :box do
YouPlot::Command.new(['box', '-H', '-d,', '-t', 'IRIS-BOXPLOT']).run
assert_equal fixture('iris-boxplot.txt'), @stderr_file.read
end
# test :c do # test :c do
# YouPlot::Command.new(['count', '-H', '-d,']).run # YouPlot::Command.new(['count', '-H', '-d,']).run
# assert_equal fixture('iris-count.txt'), @stderr_file.read # assert_equal fixture('iris-count.txt'), @stderr_file.read

View File

@ -34,11 +34,8 @@ class YouPlotSimpleTest < Test::Unit::TestCase
File.read(File.expand_path("../fixtures/#{fname}", __dir__)) File.read(File.expand_path("../fixtures/#{fname}", __dir__))
end end
test :bar do # Single command
assert_raise(ArgumentError) do # The goal is to verify that the command works without any options.
YouPlot::Command.new(['bar']).run
end
end
test :barplot do test :barplot do
assert_raise(ArgumentError) do assert_raise(ArgumentError) do
@ -46,9 +43,10 @@ class YouPlotSimpleTest < Test::Unit::TestCase
end end
end end
test :hist do test :bar do
YouPlot::Command.new(['hist']).run assert_raise(ArgumentError) do
assert_equal fixture('simple-histogram.txt'), @stderr_file.read YouPlot::Command.new(['bar']).run
end
end end
test :histogram do test :histogram do
@ -56,9 +54,9 @@ class YouPlotSimpleTest < Test::Unit::TestCase
assert_equal fixture('simple-histogram.txt'), @stderr_file.read assert_equal fixture('simple-histogram.txt'), @stderr_file.read
end end
test :line do test :hist do
YouPlot::Command.new(['line']).run YouPlot::Command.new(['hist']).run
assert_equal fixture('simple-lineplot.txt'), @stderr_file.read assert_equal fixture('simple-histogram.txt'), @stderr_file.read
end end
test :lineplot do test :lineplot do
@ -66,10 +64,9 @@ class YouPlotSimpleTest < Test::Unit::TestCase
assert_equal fixture('simple-lineplot.txt'), @stderr_file.read assert_equal fixture('simple-lineplot.txt'), @stderr_file.read
end end
test :lines do test :line do
assert_raise(YouPlot::Backends::UnicodePlot::Error) do YouPlot::Command.new(['line']).run
YouPlot::Command.new(['lines']).run assert_equal fixture('simple-lineplot.txt'), @stderr_file.read
end
end end
test :lineplots do test :lineplots do
@ -78,9 +75,9 @@ class YouPlotSimpleTest < Test::Unit::TestCase
end end
end end
test :s do test :lines do
assert_raise(YouPlot::Backends::UnicodePlot::Error) do assert_raise(YouPlot::Backends::UnicodePlot::Error) do
YouPlot::Command.new(['s']).run YouPlot::Command.new(['lines']).run
end end
end end
@ -90,9 +87,9 @@ class YouPlotSimpleTest < Test::Unit::TestCase
end end
end end
test :d do test :s do
assert_raise(YouPlot::Backends::UnicodePlot::Error) do assert_raise(YouPlot::Backends::UnicodePlot::Error) do
YouPlot::Command.new(['d']).run YouPlot::Command.new(['s']).run
end end
end end
@ -102,9 +99,10 @@ class YouPlotSimpleTest < Test::Unit::TestCase
end end
end end
test :box do test :d do
YouPlot::Command.new(['box']).run assert_raise(YouPlot::Backends::UnicodePlot::Error) do
assert_equal fixture('simple-boxplot.txt'), @stderr_file.read YouPlot::Command.new(['d']).run
end
end end
test :boxplot do test :boxplot do
@ -112,9 +110,9 @@ class YouPlotSimpleTest < Test::Unit::TestCase
assert_equal fixture('simple-boxplot.txt'), @stderr_file.read assert_equal fixture('simple-boxplot.txt'), @stderr_file.read
end end
test :c do test :box do
YouPlot::Command.new(['count']).run YouPlot::Command.new(['box']).run
assert_equal fixture('simple-count.txt'), @stderr_file.read assert_equal fixture('simple-boxplot.txt'), @stderr_file.read
end end
test :count do test :count do
@ -122,6 +120,11 @@ class YouPlotSimpleTest < Test::Unit::TestCase
assert_equal fixture('simple-count.txt'), @stderr_file.read assert_equal fixture('simple-count.txt'), @stderr_file.read
end end
test :c do
YouPlot::Command.new(['count']).run
assert_equal fixture('simple-count.txt'), @stderr_file.read
end
test :plot_output_stdout do test :plot_output_stdout do
YouPlot::Command.new(['line', '-o']).run YouPlot::Command.new(['line', '-o']).run
assert_equal '', @stderr_file.read assert_equal '', @stderr_file.read