Sha256: 1bbf2b1b0f90f29205a78474397ee6d4edc92f804c03d0632a1e5a0ac7161cda

Contents?: true

Size: 780 Bytes

Versions: 90

Compression:

Stored size: 780 Bytes

Contents

require 'exercise_cases'

class DifferenceOfSquaresCase < OpenStruct
  def test_name
    'test_%s' % description.gsub(/[ -]/, '_')
  end

  def do
    "Squares.new(#{number}).#{action}"
  end

  def action
    return 'difference' if section == 'difference_of_squares'
    section
  end

  def skipped?
    index > 0
  end

  def expected_formatted
    expected.to_s.reverse.scan(/\d{1,3}/).join('_').reverse
  end
end

DifferenceOfSquaresCases = proc do |data|
  i = 0
  json = JSON.parse(data)
  cases = []
  %w(square_of_sum sum_of_squares difference_of_squares).each do |section|
    json[section]['cases'].each do |row|
      row = row.merge(row.merge('index' => i, 'section' => section))
      cases << DifferenceOfSquaresCase.new(row)
      i += 1
    end
  end
  cases
end

Version data entries

90 entries across 90 versions & 1 rubygems

Version Path
trackler-2.1.0.1 tracks/ruby/lib/difference_of_squares_cases.rb
trackler-2.1.0.0 tracks/ruby/lib/difference_of_squares_cases.rb
trackler-2.0.8.55 tracks/ruby/lib/difference_of_squares_cases.rb
trackler-2.0.8.54 tracks/ruby/lib/difference_of_squares_cases.rb
trackler-2.0.8.53 tracks/ruby/lib/difference_of_squares_cases.rb
trackler-2.0.8.52 tracks/ruby/lib/difference_of_squares_cases.rb
trackler-2.0.8.51 tracks/ruby/lib/difference_of_squares_cases.rb
trackler-2.0.8.50 tracks/ruby/lib/difference_of_squares_cases.rb
trackler-2.0.8.49 tracks/ruby/lib/difference_of_squares_cases.rb
trackler-2.0.8.48 tracks/ruby/lib/difference_of_squares_cases.rb
trackler-2.0.8.47 tracks/ruby/lib/difference_of_squares_cases.rb
trackler-2.0.8.46 tracks/ruby/lib/difference_of_squares_cases.rb
trackler-2.0.8.45 tracks/ruby/lib/difference_of_squares_cases.rb
trackler-2.0.8.44 tracks/ruby/lib/difference_of_squares_cases.rb
trackler-2.0.8.43 tracks/ruby/lib/difference_of_squares_cases.rb
trackler-2.0.8.42 tracks/ruby/lib/difference_of_squares_cases.rb
trackler-2.0.8.41 tracks/ruby/lib/difference_of_squares_cases.rb
trackler-2.0.8.40 tracks/ruby/lib/difference_of_squares_cases.rb
trackler-2.0.8.39 tracks/ruby/lib/difference_of_squares_cases.rb
trackler-2.0.8.38 tracks/ruby/lib/difference_of_squares_cases.rb