<html>
<head>
<style><!--
  body {background-color:#ffffff;}
  .file {border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;}
  .pathname {font-family:monospace; float:right;}
  .fileheader {margin-bottom:.5em;}
  .diff {margin:0;}
  .tasklist {padding:4px;border:1px dashed #000000;margin-top:1em;}
  .tasklist ul {margin-top:0;margin-bottom:0;}
  tr.alt {background-color:#eeeeee}
  #added {background-color:#ddffdd;}
  #addedchars {background-color:#99ff99;font-weight:bolder;}
  tr.alt #added {background-color:#ccf7cc;}
  #removed {background-color:#ffdddd;}
  #removedchars {background-color:#ff9999;font-weight:bolder;}
  tr.alt #removed {background-color:#f7cccc;}
  #copied {background-color:#ccccff;}
  tr.alt #copied {background-color:#bbbbf7;}
  #info {color:#888888;}
  #context {background-color:#eeeeee;}
  td {padding-left:.3em;padding-right:.3em;}
  tr.head {border-bottom-width:1px;border-bottom-style:solid;}
  tr.head td {padding:0;padding-top:.2em;}
  .task {background-color:#ffff00;}
  .comment {white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;white-space:pre-wrap;word-wrap:break-word;padding:4px;border:1px dashed #000000;background-color:#ffffdd}
  .error {color:red;}
  hr {border-width:0px;height:2px;background:black;}
--></style>
</head>
<body>
<table cellspacing="0" cellpadding="0" border="0" rules="cols">
<tr class="head"><td colspan="5">Commit in <b><tt>as2api/trunk/as2api/tests</tt></b></td></tr>
<tr><td><tt><a href="#file1"><span id="added">mock_api.rb</span></a></tt> </td><td></td><td align="right" id="added">+115</td><td></td><td nowrap="nowrap" align="right">added 322</td></tr>
<tr class="alt"><td><tt><a href="#file2"><span id="added">run.sh</span></a></tt> </td><td></td><td align="right" id="added">+9</td><td></td><td nowrap="nowrap" align="right">added 322</td></tr>
<tr><td><tt><a href="#file3">run.sh</a></tt> </td><td align="right"><small id="info">[props]</small></td><td align="right" id="added">+1</td><td></td><td nowrap="nowrap" align="center">321 -&gt; 322</td></tr>
<tr class="alt"><td><tt><a href="#file4"><span id="added">tc_api_serializer.rb</span></a></tt> </td><td></td><td align="right" id="added">+124</td><td></td><td nowrap="nowrap" align="right">added 322</td></tr>
<tr><td><tt><a href="#file5"><span id="added">ts.rb</span></a></tt> </td><td></td><td align="right" id="added">+2</td><td></td><td nowrap="nowrap" align="right">added 322</td></tr>
<tr><td></td><td></td><td align="right" id="added">+251</td><td></td><td></td></tr>
</table>
<small id="info">4 added + 1 modified properties, total 5 files</small><br />
<div class="tasklist"><ul>
<li><a href="#task1">TODO: use proper ver once factored out from ui/cli.rb,</a></li>
</ul></div>
<pre class="comment">
Unit tests for API serialization/deserialization code
</pre>
<hr /><a name="file1" /><div class="file">
<span class="pathname" id="added">as2api/trunk/as2api/tests</span><br />
<div class="fileheader" id="added"><big><b>mock_api.rb</b></big> <small id="info">added at 322</small></div>
<pre class="diff"><small id="info">--- trunk/as2api/tests/mock_api.rb        2006-03-22 19:41:03 UTC (rev 321)
+++ trunk/as2api/tests/mock_api.rb        2006-03-22 20:11:03 UTC (rev 322)
@@ -0,0 +1,115 @@
</small></pre><pre class="diff" id="added">+
+require 'api_loader'
+require 'stringio'
+
+
+module MockAPI
+
<a name="task1" />+  # <span class="task">TODO</span>: use proper ver once factored out from ui/cli.rb,
+  SourceFile = Struct.new(:prefix, :suffix)
+
+  def self.create
+    type_aggregator = GlobalTypeAggregator.new
+    type_aggregator.add_type(create_TestClass)
+    type_aggregator.add_type(create_TestInterface)
+    type_aggregator.add_type(create_AInterface)
+    type_aggregator.add_type(create_AClass)
+    type_aggregator.add_type(create_BClass)
+    type_resolver = TypeResolver.new([])
+    type_resolver.resolve_types(type_aggregator)
+    type_aggregator
+  end
+
+  def self.create_TestClass
+    parse_file "TestClass.as", &lt;&lt;-END
+      /**
+       * Test class
+       */
+      class TestClass implements TestInterface {
+        /**
+         * A text field {@link #doSoemthing()}
+         */
+        public var text:AClass;
+
+        private var number:pkg.BClass;
+
+        /**
+         * Test constructor.
+         */
+        public function TextClass() {
+        }
+
+        /**
+         * Does some stuff
+         * 
+         * @param anArg some argument value
+         * @return some resulting string
+         *
+         * @throws TestInterface when the workld ends
+         */
+        public function doSomething(anArg:AClass):pkg.BClass {
+        }
+      }
+    END
+  end
+
+  def self.create_AClass
+    parse_file "AClass.as", &lt;&lt;-END
+      /**
+       * A class
+       * 
+       * @see TestInterface
+       */
+      class AClass {
+        public function noDocs(foo):pkg.BClass { }
+      }
+    END
+  end
+
+  def self.create_BClass
+    parse_file "pkg/BClass.as", &lt;&lt;-END
+      /**
+       * B class
+       */
+      class pkg.BClass extends AClass {
+      }
+    END
+  end
+
+  def self.create_TestInterface
+    parse_file "TestInterface.as", &lt;&lt;-END
+      /**
+       * Test interface {@link pkg.BClass text for link}.
+       */
+      interface TestInterface {
+      }
+    END
+  end
+
+  def self.create_AInterface
+    parse_file "AInterface.as", &lt;&lt;-END
+      /**
+       * A interface
+       *
+       * @see AClass some link text
+       */
+      interface AInterface extends TestInterface {
+      }
+    END
+  end
+
+  def self.parse_file(mock_filename, sourcecode)
+    io = StringIO.new(sourcecode)
+    lex = ActionScript::Parse::ASLexer.new(io)
+    lex.source = mock_filename
+    skip = DocASLexer.new(lex)
+    parse = DocASParser.new(skip)
+    handler = DocASHandler.new(mock_filename)
+    parse.handler = handler
+    parse.parse_compilation_unit
+    handler.defined_type.input_file = SourceFile.new("", mock_filename)
+    handler.defined_type
+  end
+end
+
+# vim:sw=2:sts=2
</pre></div>
<hr /><a name="file2" /><div class="file">
<span class="pathname" id="added">as2api/trunk/as2api/tests</span><br />
<div class="fileheader" id="added"><big><b>run.sh</b></big> <small id="info">added at 322</small></div>
<pre class="diff"><small id="info">--- trunk/as2api/tests/run.sh        2006-03-22 19:41:03 UTC (rev 321)
+++ trunk/as2api/tests/run.sh        2006-03-22 20:11:03 UTC (rev 322)
@@ -0,0 +1,9 @@
</small></pre><pre class="diff" id="added">+#!/bin/sh
+
+if [ "$1" == "cover" ]; then
+  rb="/home/dave/opt/bin/rcov --exclude-only=/usr/lib"
+else
+  rb="ruby -w"
+fi
+
+$rb -I .. ./ts.rb
</pre></div>
<hr /><a name="file3" /><div class="file">
<span class="pathname">as2api/trunk/as2api/tests</span><br />
<div class="fileheader"><big><b>run.sh</b></big> <small id="info">321 -&gt; 322</small></div>
<pre class="diff"><small id="info">
Property changes:

</small></pre><pre class="diff" id="added">+ svn:executable:*
</pre><pre class="diff" id="">
</pre></div>
<hr /><a name="file4" /><div class="file">
<span class="pathname" id="added">as2api/trunk/as2api/tests</span><br />
<div class="fileheader" id="added"><big><b>tc_api_serializer.rb</b></big> <small id="info">added at 322</small></div>
<pre class="diff"><small id="info">--- trunk/as2api/tests/tc_api_serializer.rb        2006-03-22 19:41:03 UTC (rev 321)
+++ trunk/as2api/tests/tc_api_serializer.rb        2006-03-22 20:11:03 UTC (rev 322)
@@ -0,0 +1,124 @@
</small></pre><pre class="diff" id="added">+# 
+# Part of as2api - http://www.badgers-in-foil.co.uk/projects/as2api/
+#
+# Copyright (c) 2006 David Holroyd, and contributors.
+#
+# See the file 'COPYING' for terms of use of this code.
+#
+
+require 'test/unit'
+require 'stringio'
+require 'output/diff/api_serializer'
+require 'output/diff/api_deserializer'
+require 'mock_api'
+require 'api_loader'
+
+class TC_APISerializer &lt; Test::Unit::TestCase
+  def test_simple
+    io = StringIO.new
+    api_name = "Mock API"
+    api_version = "1.0"
+    ser = APISerializer.new(io, api_name, api_version)
+    expected_type_aggregator = MockAPI.create
+    ser.serialize_api(expected_type_aggregator)
+    io.rewind
+    deser = APIDeserializer.new(io)
+    result_type_aggregator, actual_api_name, actual_ver = deser.deserialize_api
+    assert_equal(api_name, actual_api_name)
+    assert_equal(api_version, actual_ver)
+    assert_api_match(expected_type_aggregator, result_type_aggregator)
+  end
+
+  def assert_api_match(expected, actual)
+    expected_types = expected.types
+    actual_types = actual.types
+    assert_equal(expected_types.length, actual_types.length, "Number of types differ")
+    index = 0
+    expected_types.each do |expected_type|
+      assert_type_match(expected_type, actual_types[index])
+      index += 1
+    end
+  end
+
+  def assert_type_match(expected_type, actual_type)
+    assert_equal(expected_type.qualified_name, actual_type.qualified_name)
+    assert_comments_equal(expected_type.comment, actual_type.comment)
+    if expected_type.respond_to?(:interfaces)
+      assert_equal(expected_type.interfaces.map{|i|i.name}, actual_type.interfaces.map{|i|i.name})
+    end
+    assert_members_equal(expected_type, actual_type)
+  end
+
+  def assert_members_equal(expected_type, actual_type)
+    assert_methods_equal(expected_type, actual_type)
+    assert_fields_equal(expected_type, actual_type) if expected_type.respond_to?(:fields)
+  end
+
+  def assert_methods_equal(expected_type, actual_type)
+    expected_methods = expected_type.methods
+    actual_methods = actual_type.methods
+    assert_same(expected_methods.length, actual_methods.length)
+    expected_methods.each_with_index do |expected_method, index|
+      assert_method_equal(expected_method, actual_methods[index])
+    end
+  end
+
+  def assert_method_equal(expected_method, actual_method)
+    assert_equal(expected_method.name, actual_method.name)
+    assert_equal(expected_method.access, actual_method.access)
+    assert_comments_equal(expected_method.comment, actual_method.comment)
+  end
+
+  def assert_fields_equal(expected_type, actual_type)
+    expected_fields = expected_type.fields
+    actual_fields = actual_type.fields
+    assert_same(expected_fields.length, actual_fields.length)
+    expected_fields.each_with_index do |expected_field, index|
+      assert_field_equal(expected_field, actual_fields[index])
+    end
+  end
+
+  def assert_field_equal(expected_field, actual_field)
+    assert_equal(expected_field.name, actual_field.name)
+    assert_access_equal(expected_field.access, actual_field.access)
+    # cheat with line numbers, since these are not available in the xml dump
+    if actual_field.field_type
+      actual_field.field_type.lineno = expected_field.field_type.lineno
+    end
+    assert_equal(expected_field.field_type, actual_field.field_type)
+    assert_comments_equal(expected_field.comment, actual_field.comment)
+  end
+
+  def assert_access_equal(expected_access, actual_access)
+  end
+
+  def assert_comments_equal(expected_comment_data, actual_comment_data)
+    index = 0
+    return if expected_comment_data.nil? &amp;&amp; actual_comment_data.nil?
+    assert_equal(expected_comment_data.nil?, actual_comment_data.nil?,
+                 actual_comment_data.inspect)
+    assert_not_nil(actual_comment_data, "Comment missing")
+    expected_comment_data.each_block do |expected_block|
+      assert_comment_block_equal(expected_block, actual_comment_data[index])
+      index += 1
+    end
+  end
+
+  def assert_comment_block_equal(expected_block, actual_block)
+    assert_same(expected_block.class, actual_block.class, "#{expected_block.inspect} expected, but found #{actual_block.inspect}")
+    assert_equal(expected_block.inlines.length, actual_block.inlines.length,
+                 "Number of inlines differ in #{expected_block.class.name}")
+    # cheat, and copy the expected line numbers into the actual inlines,
+    # as the XML format doesn't carry the line numbers from the orig src
+    expected_block.inlines.each_with_index do |expected_inline, index|
+      actual_inline = actual_block.inlines[index]
+      actual_inline.lineno = expected_inline.lineno if expected_inline.respond_to?(:lineno)
+      if expected_inline.respond_to?(:target) &amp;&amp; expected_inline.target
+        actual_inline.target.lineno = expected_inline.target.lineno
+      end
+    end
+    assert_equal(expected_block, actual_block)
+  end
+end
+
+# vim:sw=2:sts=2
</pre></div>
<hr /><a name="file5" /><div class="file">
<span class="pathname" id="added">as2api/trunk/as2api/tests</span><br />
<div class="fileheader" id="added"><big><b>ts.rb</b></big> <small id="info">added at 322</small></div>
<pre class="diff"><small id="info">--- trunk/as2api/tests/ts.rb        2006-03-22 19:41:03 UTC (rev 321)
+++ trunk/as2api/tests/ts.rb        2006-03-22 20:11:03 UTC (rev 322)
@@ -0,0 +1,2 @@
</small></pre><pre class="diff" id="added">+
+require 'tc_api_serializer'
</pre></div>
<center><small><a href="http://www.badgers-in-foil.co.uk/projects/cvsspam/" title="commit -&gt; email">CVSspam</a> 0.2.12</small></center>
</body></html>