Sha256: bf90a3a1cbb8e9af6f6da41f92112ad137dd89ef73be170d8ff77678244395c1

Contents?: true

Size: 636 Bytes

Versions: 4

Compression:

Stored size: 636 Bytes

Contents

require 'spec_helper'
require 'dentaku/ast/function'

describe Dentaku::AST::Function do
  it 'maintains a function registry' do
    expect(described_class).to respond_to(:get)
  end

  it 'raises an exception when trying to access an undefined function' do
    expect { described_class.get("flarble") }.to raise_error(RuntimeError, /undefined function/i)
  end

  it 'registers a custom function' do
    described_class.register("flarble", :string, -> { "flarble" })
    expect { described_class.get("flarble") }.not_to raise_error
    function = described_class.get("flarble").new
    expect(function.value).to eq "flarble"
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dentaku-2.0.6 spec/ast/function_spec.rb
dentaku-2.0.5 spec/ast/function_spec.rb
dentaku-2.0.4 spec/ast/function_spec.rb
dentaku-2.0.3 spec/ast/function_spec.rb