Sha256: 601c0b986b73b49556d199daa35aaf570cceb7e7d330b15f423f1ca0f795cdef

Contents?: true

Size: 1.14 KB

Versions: 2

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

2 entries across 2 versions & 1 rubygems

Version Path
qlang-0.0.14 spec/matrix_spec.rb
qlang-0.0.1 spec/matrix_spec.rb