File: jruby_spec.rb

package info (click to toggle)
jruby 9.4.8.0%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 89,244 kB
  • sloc: ruby: 548,574; java: 276,189; yacc: 25,873; ansic: 6,178; xml: 6,111; sh: 1,855; sed: 94; makefile: 78; jsp: 48; tcl: 40; exp: 12
file content (44 lines) | stat: -rw-r--r-- 1,161 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
require File.dirname(__FILE__) + "/../spec_helper"

describe "JRuby#compile" do
  it "should produce a CompiledScript instance" do
    require 'jruby'
    compiled = JRuby.compile("foo = 1")
    expect(compiled).to be_kind_of JRuby::CompiledScript
  end
end

describe "JRuby::CompiledScript#inspect_bytecode" do
  it "should produce a String representation of the compiled bytecode" do
    require 'jruby'
    compiled = JRuby.compile("foo = 1")
    bytecode = compiled.inspect_bytecode

    expect(bytecode).to be_kind_of String
  end
end

describe "JRuby#compile_ir" do
  it "should return an IR script body" do
    require 'jruby'
    compiled = JRuby.compile_ir("foo = 1; bar = 2", 'foobar.rbx')

    expect(compiled.file_name).to eql 'foobar.rbx'
  end
end

describe "JRuby#parse" do
  it "as bytes" do
    require 'jruby'
    node = JRuby.parse('bar = :bar; bar.to_s * 111'.force_encoding('ASCII-8BIT'), '')

    expect(node).to be_kind_of org.jruby.ast.RootNode
  end

  it "as string" do
    require 'jruby'
    node = JRuby.parse('baz = :baz; baz.to_s + " "'.force_encoding('UTF-8'), '')

    expect(node).to be_kind_of org.jruby.ast.RootNode
  end
end