Sha256: 17808e71ee02851507bf58939405e415babb496900e1c35c1e236e9cfeb94eca
Contents?: true
Size: 1.05 KB
Versions: 11
Compression:
Stored size: 1.05 KB
Contents
require 'spec_helper' require 'dentaku/ast/node' require 'dentaku/tokenizer' require 'dentaku/parser' describe Dentaku::AST::Node do it 'returns list of dependencies' do node = make_node('x + 5') expect(node.dependencies).to eq(['x']) node = make_node('5 < x') expect(node.dependencies).to eq(['x']) node = make_node('5 < 7') expect(node.dependencies).to eq([]) node = make_node('(y * 7)') expect(node.dependencies).to eq(['y']) node = make_node('if(x > 5, y, z)') expect(node.dependencies).to eq(['x', 'y', 'z']) node = make_node('if(x > 5, y, z)') expect(node.dependencies('x' => 7)).to eq(['y']) node = make_node('if(x > 5, y, z)') expect(node.dependencies('x' => 2)).to eq(['z']) node = make_node('') expect(node.dependencies).to eq([]) end it 'returns unique list of dependencies' do node = make_node('x + x') expect(node.dependencies).to eq(['x']) end private def make_node(expression) Dentaku::Parser.new(Dentaku::Tokenizer.new.tokenize(expression)).parse end end
Version data entries
11 entries across 11 versions & 2 rubygems