Ignore:
Timestamp:
Oct 15, 2009, 7:28:12 AM (15 years ago)
Author:
Tatsukawa, Akimichi
Message:

refactoring scanner for regex

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ruby/trunk/lib/adl_parser/test/scanner_test.rb

    r319 r320  
    7474  end
    7575
     76  must "assert CADLScanner scanner scan V_STRING" do
     77    @scanner.scan("\"string\"") do |sym, val|
     78      assert_equal :V_STRING,sym
     79      assert_equal "string",val
     80    end
     81    @scanner.scan("\"1605E211E9BFB4093A72CCE7A9792FF9\"") do |sym, val|
     82      assert_equal :V_STRING,sym
     83      assert_equal "1605E211E9BFB4093A72CCE7A9792FF9",val
     84    end
     85  end
     86
    7687  must "assert CADLScanner scanner scan V_QUALIFIED_TERM_CODE_REF" do
    7788    @scanner.scan("[ICD10AM(1998)::F23]") do |sym, val|
    7889      assert_equal :V_QUALIFIED_TERM_CODE_REF,sym
    7990      assert_equal "ICD10AM(1998)::F23",val
     91    end
     92  end
     93
     94
     95  must "assert CADLScanner scanner scan V_ISO8601_DURATION_CONSTRAINT_PATTERN" do
     96    @scanner.scan("PW") do |sym, val|
     97      assert_equal :V_ISO8601_DURATION_CONSTRAINT_PATTERN,sym
     98      assert_equal "PW",val
     99    end
     100    @scanner.scan("PTs") do |sym, val|
     101      assert_equal :V_ISO8601_DURATION_CONSTRAINT_PATTERN,sym
     102      assert_equal "PTs",val
    80103    end
    81104  end
     
    89112    @scanner.scan("P1D") do |sym, val|
    90113      assert_equal :V_ISO8601_DURATION,sym
    91       assert_equal "PT1M",val
     114      assert_equal "P1D",val
     115    end
     116
     117    @scanner.scan("PT1H30M") do |sym, val|
     118      assert_equal :V_ISO8601_DURATION,sym
     119      assert_equal "PT1H30M",val
    92120    end
    93121  end
    94122
    95   must "assert CADLScanner scanner scan V_STRING" do
    96     @scanner.scan("\"string\"") do |sym, val|
    97       assert_equal :V_STRING,sym
    98       assert_equal "string",val
    99     end
    100     @scanner.scan("\"1605E211E9BFB4093A72CCE7A9792FF9\"") do |sym, val|
    101       assert_equal :V_STRING,sym
    102       assert_equal "1605E211E9BFB4093A72CCE7A9792FF9",val
     123  must "assert CADLScanner scanner scan V_ISO8601_EXTENDED_DATE_TIME" do
     124    @scanner.scan("2000-01-01T01:00:00") do |sym, val|
     125      assert_equal :V_ISO8601_EXTENDED_DATE_TIME,sym
     126      assert_equal "2000-01-01T01:00:00",val
    103127    end
    104128  end
    105129
    106   must "assert CADLScanner scanner scan V_ISO8601_DURATION_CONSTRAINT_PATTERN" do
    107     @scanner.scan("PW") do |sym, val|
    108       assert_equal :V_ISO8601_DURATION_CONSTRAINT_PATTERN,sym
    109       assert_equal "PW",val
    110     end
    111   end
    112130end
    113131
     
    155173  end
    156174end
     175
     176class RegexScannerTest < Test::Unit::TestCase
     177  def setup
     178    @scanner = OpenEhr::ADL::Scanner::RegexScanner.new([:regexp], "filename")
     179  end
     180
     181  must "assert RegexScanner scanner scan " do
     182    @scanner.scan("this|that|something else") do |sym, val|
     183      assert_equal :REGEXP_BODY,sym
     184      assert_equal "this|that|something else",val
     185    end
     186  end
     187end
Note: See TracChangeset for help on using the changeset viewer.