|
From: <luk...@us...> - 2006-09-06 06:01:09
|
Revision: 82
http://svn.sourceforge.net/asunit/?rev=82&view=rev
Author: lukebayes
Date: 2006-09-05 23:01:00 -0700 (Tue, 05 Sep 2006)
Log Message:
-----------
almost have it sort of working...
Modified Paths:
--------------
trunk/ruby/src/asunit.rb
trunk/ruby/src/settings.rb
trunk/ruby/src/templates/TestCase.erb
Added Paths:
-----------
trunk/ruby/.asunit
Added: trunk/ruby/.asunit
===================================================================
--- trunk/ruby/.asunit (rev 0)
+++ trunk/ruby/.asunit 2006-09-06 06:01:00 UTC (rev 82)
@@ -0,0 +1,7 @@
+---
+project: Lifebin
+src: demo/src
+test: demo/test
+templates: src/templates
+file_extension: .as
+classpath:
\ No newline at end of file
Modified: trunk/ruby/src/asunit.rb
===================================================================
--- trunk/ruby/src/asunit.rb 2006-09-06 05:26:38 UTC (rev 81)
+++ trunk/ruby/src/asunit.rb 2006-09-06 06:01:00 UTC (rev 82)
@@ -39,36 +39,48 @@
end
end
+ require 'yaml'
require 'optparse'
+ require 'settings'
+ require 'create_class'
class Application
@@PROJECT_FILE_NAME = '.asunit'
-
+ @@CLASS_TEMPLATE = 'Class.erb'
+ @@TEST_TEMPLATE = 'TestCase.erb'
+
def initialize
super
arguments = AsUnitArguments.new(ARGV)
project_file = get_project_file Dir.pwd
- puts 'pf dir: ' + Dir.pwd
- puts 'pf: ' + project_file.read
+ prefs = YAML.load(project_file.read)
+ settings = AsUnit::Settings.new(prefs)
+
arguments.classnames.each { |name|
- create_class name
+ if(name.ends_with? "Test")
+ create_class(name, settings, @@TEST_TEMPLATE)
+ else
+ create_class(name, settings, @@CLASS_TEMPLATE)
+ create_class(name + "Test", settings, @@TEST_TEMPLATE)
+ end
}
end
+ def create_class(name, settings, template)
+ created_class = AsUnit::CreateClass.new(name, settings, template)
+ created_class.run
+ end
+
def get_project_file(dir)
if(dir == '/')
- raise 'Project file not found, please create a new asunit project by typing "asunit -create-project ProjectName"'
+ raise 'Project file not found, please create a new asunit project by typing "asunit -create-project [-src, -test, -templates]"'
end
Dir.chdir dir
if(File.exists? @@PROJECT_FILE_NAME)
return File.open(@@PROJECT_FILE_NAME, 'r')
end
- get_project_file(File.dirname dir)
- end
-
- def create_class(name)
- puts 'name: ' + name
- end
+ get_project_file(File.dirname(dir))
+ end
end
class AsUnitArguments < Hash
@@ -143,6 +155,12 @@
end
end
+class String
+ def ends_with? str
+ return false
+ end
+end
+
if __FILE__ == $0 then
AsUnit::Application.new
end
Modified: trunk/ruby/src/settings.rb
===================================================================
--- trunk/ruby/src/settings.rb 2006-09-06 05:26:38 UTC (rev 81)
+++ trunk/ruby/src/settings.rb 2006-09-06 06:01:00 UTC (rev 82)
@@ -5,12 +5,26 @@
attr_accessor :src, :test, :templates, :file_extension, :directories
- def initialize
+ def initialize(hash)
@directories = ['src', 'test', 'templates', 'css', 'xml']
@src = 'src'
@test = 'test'
@templates = 'templates'
@file_extension = @@FILE_EXTENSION
+
+ if(!hash['src'].nil?)
+ @src = hash['src']
+ end
+ if(!hash['test'].nil?)
+ @test = hash['test']
+ end
+ if(!hash['templates'].nil?)
+ @templates = hash['templates']
+ end
+ if(!hash['file_extension'].nil?)
+ @file_extension = hash['file_extension']
+ end
+
end
end
end
\ No newline at end of file
Modified: trunk/ruby/src/templates/TestCase.erb
===================================================================
--- trunk/ruby/src/templates/TestCase.erb 2006-09-06 05:26:38 UTC (rev 81)
+++ trunk/ruby/src/templates/TestCase.erb 2006-09-06 06:01:00 UTC (rev 82)
@@ -1,29 +1,35 @@
-package lifebin.controls {
+package <%= package %>{
import asunit.framework.TestCase;
-
+
public class <%= classname %> extends TestCase {
private var instance:<%= classname %>;
-
- public function <%= classname %>Test(testMethod:String = null) {
+
+ public function <%= classname %>(testMethod:String = null) {
super(testMethod);
}
-
+
protected override function setUp():void {
super.setUp();
instance = new <%= classname %>();
+ <% if visual? %>
+ addChild(instance);
+ <% end %>
}
-
+
protected override function tearDown():void {
super.tearDown();
+ <% if visual? %>
+ removeChild(instance);
+ <% end %>
instance = null;
}
-
+
public function testInstantiated():void {
assertTrue("<%= classname %> instantiated", instance is <%= classname %>);
}
-
+
public function test():void {
- assertTrue('default failing test', false);
+ assertTrue("<%= classname %> default failing test", false);
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|