Class: TestKyaniteFSymbols
- Defined in
- test/test_fsymbol.rb
CallerUtils
- Kyanite definitions
- Kyanite tests and examples
- Usage
-
require ‘kyanite/fsymbol’
A FSymbol (“focusable Symbol”) is a comparable Symbol within a hierarchy. You can use it for classifications. In its values, it is limited to the values, which are defined in the hierarchy. FSymbols are comparable with <= >= <=>. A more specific FSymbol is larger than a more general FSymbol (because the specific FSymbol contains more information) E.g. if you define a hierarchy if animal species, you can say:
:insect.to_f_symbol <= :bee.to_f_symbol
FSymbols are equal to Symbols with the same name.
Instance Method Summary (collapse)
- - (Object) setup
- - (Object) test_all_child_keys
- - (Object) test_first
- - (Object) test_raise
- - (Object) test_root
- - (Object) test_specific
- - (Object) test_tokencodes
Instance Method Details
- (Object) setup
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'test/test_fsymbol.rb', line 17 def setup unless defined? $def_tree # Oberste Ebene ttroot = Tree::TreeNode.new(:root) ttroot << Tree::TreeNode.new(:item) ttroot << Tree::TreeNode.new(:num) ttroot << Tree::TreeNode.new(:site) << Tree::TreeNode.new(:url) ttroot << Tree::TreeNode.new(:sonstiges) # :singlechar ttroot << Tree::TreeNode.new(:singlechar) ttroot[:singlechar] << Tree::TreeNode.new(:struktur) << Tree::TreeNode.new(:punkt) << Tree::TreeNode.new(:satzende) ttroot[:singlechar] << Tree::TreeNode.new(:minus) ttroot[:singlechar] << Tree::TreeNode.new(:sonderzeichen) # :item ttroot[:item] << (wa_word=Tree::TreeNode.new(:de)) << Tree::TreeNode.new(:name) wa_word << Tree::TreeNode.new(:abbrev) wa_word << Tree::TreeNode.new(:multi) $def_tree = ttroot #$def_tree.print_tree end @tokencodes = [:num, :url, :site, :item, :punkt, :minus, :struktur, :sonderzeichen, :sonstiges, :singlechar, :satzende, :de, :abbrev, :name, :multi] @root = :root.to_fsymbol($def_tree) end |
- (Object) test_all_child_keys
70 71 72 73 74 75 |
# File 'test/test_fsymbol.rb', line 70 def test_all_child_keys t = @tokencodes.to_set b = FSymbol.new(:root).childs.to_set diff = ((t-b) + (b-t)).to_a assert_equal t, b, "\n\n\nDifferenz zwischen @tokencodes hier im Test und dem Definitionsbaum. \nUnterschied: #{diff}\n\n\n" end |
- (Object) test_first
49 50 51 52 53 |
# File 'test/test_fsymbol.rb', line 49 def test_first a = FSymbol.new(:item) assert_equal 'item', a.to_s assert_equal ':item', a.inspect end |
- (Object) test_raise
56 57 58 59 60 |
# File 'test/test_fsymbol.rb', line 56 def test_raise assert_raise(ArgumentError) { FSymbol.new(:idfsdgtem) } assert_raise(ArgumentError) { FSymbol.new('item') } assert_raise(ArgumentError) { FSymbol.new(nil) } end |
- (Object) test_root
78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'test/test_fsymbol.rb', line 78 def test_root assert_equal 0, @root <=> @root assert_equal 0, @root <=> :root assert @root >= @root assert @root <= @root assert @root >= @root assert @root <= @root @tokencodes.each do |c| cf = c.to_fsymbol assert_equal( -1, (@root <=> c.to_fsymbol )) assert_equal( 1, (cf <=> @root )) assert_equal( -1, (@root <=> cf )) end end |
- (Object) test_specific
94 95 96 97 98 99 100 101 |
# File 'test/test_fsymbol.rb', line 94 def test_specific assert :item.to_fsymbol <= :name.to_fsymbol assert :name.to_fsymbol >= :item.to_fsymbol assert :item.to_fsymbol <= :abbrev.to_fsymbol assert :abbrev.to_fsymbol >= :item.to_fsymbol assert :minus.to_fsymbol >= :singlechar.to_fsymbol assert :singlechar.to_fsymbol <= :minus.to_fsymbol end |
- (Object) test_tokencodes
63 64 65 66 67 |
# File 'test/test_fsymbol.rb', line 63 def test_tokencodes @tokencodes.each do |c| assert_equal c.to_s, FSymbol.new(c).to_s, "FSymbol für Tokencode :#{c} konnte nicht erzeugt werden" end end |