#!/usr/bin/env ruby require 'test/unit' currentPath = File.dirname(__FILE__) require File.join( currentPath, '../../lib/masterview' ) class TestDirectiveHelpersParse < Test::Unit::TestCase include MasterView::DirectiveHelpers def test_parse_a str = <<-END a,b,'c' END assert_equal ['a','b',"'c'"], parse(str.strip) end def test_parse_a2 str = <<-END 'a','b','c' END assert_equal ["'a'","'b'","'c'"], parse(str.strip) end def test_parse_a3 str = <<-END "a","b","c" END assert_equal ['"a"','"b"','"c"'], parse(str.strip) end def test_parse_b str = <<-END a,%q{hello,world},c END assert_equal ['a','%q{hello,world}','c'], parse(str.strip) end def test_parse_c str = <<-END a,%q[hello,world],c END assert_equal ['a','%q[hello,world]','c'], parse(str.strip) end def test_parse_d str = <<-END a,%q|hello,world|,c END assert_equal ['a','%q|hello,world|','c'], parse(str.strip) end def test_parse_e str = <<-END a,%q(hello,world),c END assert_equal ['a','%q(hello,world)','c'], parse(str.strip) end def test_parse_e2 str = <<-END a,%q,c END assert_equal ['a','%q','c'], parse(str.strip) end def test_parse_e3 str = <<-END a,%q_hello,world_,c END assert_equal ['a','%q_hello,world_','c'], parse(str.strip) end def test_parse_e4 str = <<-END a,%q hello,world ,c END assert_equal ['a','%q hello,world','c'], parse(str.strip) end def test_parse_e5 str = <<-END a,%q*hello,world*,c END assert_equal ['a','%q*hello,world*','c'], parse(str.strip) end def test_parse_e6 str = <<-END a,%q!hello,world!,c END assert_equal ['a','%q!hello,world!','c'], parse(str.strip) end def test_parse_e7 str = <<-END a,%q0hello,world0,c END assert_equal ['a','%q0hello','world0','c'], parse(str.strip) end def test_parse_e8 str = <<-END a,%qahello,worlda,c END assert_equal ['a','%qahello','worlda','c'], parse(str.strip) end def test_parse_e9 str = <<-END a,%qBhello,worldB,c END assert_equal ['a','%qBhello','worldB','c'], parse(str.strip) end def test_parse_f str = <<-END a,%Q{hello,world},c END assert_equal ['a','%Q{hello,world}','c'], parse(str.strip) end def test_parse_g str = <<-END a,%Q[hello,world],c END assert_equal ['a','%Q[hello,world]','c'], parse(str.strip) end def test_parse_h str = <<-END a,%Q|hello,world|,c END assert_equal ['a','%Q|hello,world|','c'], parse(str.strip) end def test_parse_i str = <<-END a,%Q(hello,world),c END assert_equal ['a','%Q(hello,world)','c'], parse(str.strip) end def test_parse_i2 str = <<-END a,%Q,c END assert_equal ['a','%Q','c'], parse(str.strip) end def test_parse_j str = <<-END a,[1,2, 3],c END assert_equal ['a','[1,2, 3]','c'], parse(str.strip) end def test_parse_j str = <<-END a,[1,2, 3],[4,5,6] END assert_equal ['a','[1,2, 3]','[4,5,6]'], parse(str.strip) end def test_parse_k str = <<-END a,{:a => :b, :c => :d}, {:e => 'f', :g => 1} END assert_equal ['a','{:a => :b, :c => :d}','{:e => \'f\', :g => 1}'], parse(str.strip) end def test_parse_l str = <<-END a,{:a => :b, :c => :d}, :e => 'f', :g => 1 END assert_equal ['a','{:a => :b, :c => :d}',':e => \'f\', :g => 1'], parse(str.strip) end def test_parse_l str = <<-END a,{:a => :b, :c => :d}, :e => 'f', :g => 1 END assert_equal ['a','{:a => :b, :c => :d}',':e => \'f\', :g => 1'], parse(str.strip) end def test_parse_m str = <<-END a,%r{hello,world},c END assert_equal ['a','%r{hello,world}','c'], parse(str.strip) end def test_parse_n str = <<-END a,%r[hello,world],c END assert_equal ['a','%r[hello,world]','c'], parse(str.strip) end def test_parse_o str = <<-END a,%r|hello,world|,c END assert_equal ['a','%r|hello,world|','c'], parse(str.strip) end def test_parse_p str = <<-END a,%r(hello,world),c END assert_equal ['a','%r(hello,world)','c'], parse(str.strip) end def test_parse_q str = <<-END a,%w{hello, world},c END assert_equal ['a','%w{hello, world}','c'], parse(str.strip) end def test_parse_r str = <<-END a,%w[hello, world],c END assert_equal ['a','%w[hello, world]','c'], parse(str.strip) end def test_parse_s str = <<-END a,%w|hello, world|,c END assert_equal ['a','%w|hello, world|','c'], parse(str.strip) end def test_parse_t str = <<-END a,%w(hello, world),c END assert_equal ['a','%w(hello, world)','c'], parse(str.strip) end def test_parse_u str = <<-END a,Product.find(:all).collect{|p| [p.name, p.id]},c END assert_equal ['a','Product.find(:all).collect{|p| [p.name, p.id]}','c'], parse(str.strip) end def test_parse_v str = <<-END a,{:a => :b, :c => [1,2]}, :e => [3,:g], 'h,i' => [j,k] END assert_equal ['a','{:a => :b, :c => [1,2]}',':e => [3,:g], \'h,i\' => [j,k]'], parse(str.strip) end def test_parse_w str = <<-END END assert_equal [], parse(str.strip) end def test_parse_x str = <<-END a,%(hello, world),c END assert_equal ['a','%(hello, world)','c'], parse(str.strip) end def test_parse_x2 str = <<-END a,%{hello, world},c END assert_equal ['a','%{hello, world}','c'], parse(str.strip) end def test_parse_x3 str = <<-END a,%[hello, world],c END assert_equal ['a','%[hello, world]','c'], parse(str.strip) end def test_parse_x4 str = <<-END a,%,c END assert_equal ['a','%','c'], parse(str.strip) end def test_parse_y str = <<-END a,%s(hello, world),c END assert_equal ['a','%s(hello, world)','c'], parse(str.strip) end def test_parse_z str = <<-END a,"hello, world",c END assert_equal ['a','"hello, world"','c'], parse(str.strip) end def test_parse_z0 str = <<-END a,'hello, world',c END assert_equal ['a','\'hello, world\'','c'], parse(str.strip) end def test_parse_z1 str = <<-END a,"hello, \\"world",c END assert_equal ['a',"\"hello, \\\"world\"",'c'], parse(str.strip) end def test_parse_z2 str = <<-END a,'hello, \\'world',c END assert_equal ['a','\'hello, \\\'world\'','c'], parse(str.strip) end end