File: jruby_spec.rb

package info (click to toggle)
jruby 9.3.9.0%2Bds-8
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 80,856 kB
  • sloc: ruby: 517,823; java: 260,094; xml: 31,930; ansic: 5,777; yacc: 4,973; sh: 1,163; makefile: 105; jsp: 48; tcl: 40; exp: 11
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