Sha256: abec6762d8c0eddac652a979c4d11b171feaa781b24d902bb4dd8433c527c075

Contents?: true

Size: 1.19 KB

Versions: 8

Compression:

Stored size: 1.19 KB

Contents

require 'spec_helper'

describe Hilbert do
  describe 'Matrix' do
    context 'into R' do
      it do
        expect(
          Hilbert.to_r.compile('(1 2 3; 4 5 6)')
        ).to eq(
          'matrix(c(1, 2, 3, 4, 5, 6), 2, 3, byrow = TRUE)'
        )

        expect(
          Hilbert.to_r.compile('(1 2 3 ; 4 5 6)')
        ).to eq(
          'matrix(c(1, 2, 3, 4, 5, 6), 2, 3, byrow = TRUE)'
        )

        expect(
          Hilbert.to_r.compile('(1 2 3 ; 4 5 6; 7 8 9)')
        ).to eq(
          'matrix(c(1, 2, 3, 4, 5, 6, 7, 8, 9), 3, 3, byrow = TRUE)'
        )

        expect(
          Hilbert.to_r.compile('(1;2;3)')
        ).to eq(
          'matrix(c(1, 2, 3), 3, 1, byrow = TRUE)'
        )
      end
    end

    context 'into Ruby' do
      it do
        expect(
          Hilbert.to_ruby.compile('(1 2 3; 4 5 6)')
        ).to eq(
          'Matrix[[1, 2, 3], [4, 5, 6]]'
        )

        expect(
          Hilbert.to_ruby.compile('(1 2 3 ; 4 5 6; 7 8 9)')
        ).to eq(
          'Matrix[[1, 2, 3], [4, 5, 6], [7, 8, 9]]'
        )

        expect(
          Hilbert.to_ruby.compile('(1;2;3)')
        ).to eq(
          'Matrix[[1], [2], [3]]'
        )
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
hilbert-0.0.2700420 legacy_rspec/objects/matrix_spec.rb
hilbert-0.0.2700410 legacy_rspec/objects/matrix_spec.rb
hilbert-0.0.2700400 legacy_rspec/objects/matrix_spec.rb
hilbert-0.0.2700320 legacy_rspec/objects/matrix_spec.rb
hilbert-0.0.2700300 legacy_rspec/objects/matrix_spec.rb
hilbert-0.0.2700210 legacy_rspec/objects/matrix_spec.rb
hilbert-0.0.2700110 legacy_rspec/objects/matrix_spec.rb
hilbert-0.0.2700100 legacy_rspec/objects/matrix_spec.rb