Sha256: c706fba1a0b8db18de50c781dfb1566813add5cf005e91d3c43c29b33e1b82a9

Contents?: true

Size: 1.14 KB

Versions: 17

Compression:

Stored size: 1.14 KB

Contents

require 'spec_helper'

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

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

        expect(
          Q.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(
          Q.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(
          Q.to_ruby.compile('(1 2 3; 4 5 6)')
        ).to eq(
          "Matrix[[1, 2, 3], [4, 5, 6]]"
        )

        expect(
          Q.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(
          Q.to_ruby.compile('(1;2;3)')
        ).to eq(
          "Matrix[[1], [2], [3]]"
        )
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
qlang-0.0.27182123 legacy_rspec/objects/matrix_spec.rb
qlang-0.0.27182122 legacy_rspec/objects/matrix_spec.rb
qlang-0.0.27182121 legacy_rspec/objects/matrix_spec.rb
qlang-0.0.27182120 legacy_rspec/objects/matrix_spec.rb
qlang-0.0.27182110 legacy_rspec/objects/matrix_spec.rb
qlang-0.0.27182100 legacy_rspec/objects/matrix_spec.rb
qlang-0.0.27182000 spec/objects/matrix_spec.rb
qlang-0.0.27180000 spec/objects/matrix_spec.rb
qlang-0.0.27100000 spec/objects/matrix_spec.rb
qlang-0.0.27000000 spec/objects/matrix_spec.rb
qlang-0.0.27 spec/objects/matrix_spec.rb
qlang-0.0.14142135 spec/objects/matrix_spec.rb
qlang-0.0.1414213 spec/objects/matrix_spec.rb
qlang-0.0.141421 spec/objects/matrix_spec.rb
qlang-0.0.14142 spec/matrix_spec.rb
qlang-0.0.1414 spec/matrix_spec.rb
qlang-0.0.141 spec/matrix_spec.rb