Sha256: eb70e43bf87a2440edddedc7948605b6d6e5cef803b003e5ed50eaa59fad7e7a
Contents?: true
Size: 1.33 KB
Versions: 2
Compression:
Stored size: 1.33 KB
Contents
require 'spec_helper' module Qrb describe Syntax, "sub_type" do subject{ Syntax.parse(input, root: "sub_type") } let(:compiled){ subject.compile(type_factory) } context '.Integer( i | i >= 0 )' do let(:input){ '.Integer( i | i >= 0 )' } it 'compiles to a SubType' do compiled.should be_a(SubType) compiled.super_type.should be_a(BuiltinType) compiled.super_type.ruby_type.should be(Integer) end end context '.Integer( i | positive: i >= 0 )' do let(:input){ '.Integer( i | positive: i >= 0 )' } it 'compiles to a SubType' do compiled.should be_a(SubType) compiled.super_type.should be_a(BuiltinType) compiled.super_type.ruby_type.should be(Integer) end it 'has the correct constraints' do compiled.constraints.keys.should eq([:positive]) end end context '.Integer( i | positive: i >= 0, ... )' do let(:input){ '.Integer( i | positive: i >= 0, small: i <= 255 )' } it 'compiles to a SubType' do compiled.should be_a(SubType) compiled.super_type.should be_a(BuiltinType) compiled.super_type.ruby_type.should be(Integer) end it 'has the correct constraints' do compiled.constraints.keys.should eq([:positive, :small]) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
qrb-0.2.0 | spec/unit/syntax/nodes/test_sub_type.rb |
qrb-0.1.0 | spec/unit/syntax/nodes/test_sub_type.rb |