From 8e5b9e2faf41364ad3a9de6116d53ceae8d92d71 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Sat, 24 Nov 2012 17:42:36 -0500 Subject: [PATCH] hop: BaseConfig: renaming core add task functions --- lib/hop.dart | 6 +++--- lib/src/hop/base_config.dart | 4 ++-- test/hop/async_tests.dart | 2 +- test/hop/sync_tests.dart | 6 +++--- test/hop/task_list_tests.dart | 10 +++++----- tool/hop_runner.dart | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/hop.dart b/lib/hop.dart index fd16e28b..1b7b6c59 100644 --- a/lib/hop.dart +++ b/lib/hop.dart @@ -32,10 +32,10 @@ void runHopCore() { }); } -void addTask(String name, Func1 execFunc) { - _sharedConfig.addTask(name, execFunc); +void addSyncTask(String name, Func1 execFunc) { + _sharedConfig.addSync(name, execFunc); } void addAsyncTask(String name, TaskDefinition execFuture) { - _sharedConfig.addTaskAsync(name, execFuture); + _sharedConfig.addAsync(name, execFuture); } diff --git a/lib/src/hop/base_config.dart b/lib/src/hop/base_config.dart index 9970d43c..0dcf395d 100644 --- a/lib/src/hop/base_config.dart +++ b/lib/src/hop/base_config.dart @@ -23,11 +23,11 @@ class BaseConfig { return _tasks[taskName]; } - void addTask(String name, Func1 func) { + void addSync(String name, Func1 func) { _addTask(new Task.sync(name, func)); } - void addTaskAsync(String name, TaskDefinition execFuture) { + void addAsync(String name, TaskDefinition execFuture) { _addTask(new Task.async(name, execFuture)); } diff --git a/test/hop/async_tests.dart b/test/hop/async_tests.dart index e166c9b8..3defa0b4 100644 --- a/test/hop/async_tests.dart +++ b/test/hop/async_tests.dart @@ -18,7 +18,7 @@ class AsyncTests { Action1> completeHandler) { final name = 'task_name'; final tasks = new BaseConfig(); - tasks.addTaskAsync(name, taskFuture); + tasks.addAsync(name, taskFuture); tasks.freeze(); final runner = new TestRunner(tasks, [name]); diff --git a/test/hop/sync_tests.dart b/test/hop/sync_tests.dart index 0c9f0be3..3da0270e 100644 --- a/test/hop/sync_tests.dart +++ b/test/hop/sync_tests.dart @@ -49,7 +49,7 @@ class SyncTests { static void _testBadParam() { final tasks = new BaseConfig(); - tasks.addTask('good', (ctx) => true); + tasks.addSync('good', (ctx) => true); tasks.freeze(); final runner = new TestRunner(tasks, ['bad']); @@ -67,7 +67,7 @@ class SyncTests { static void _testNoParam() { final tasks = new BaseConfig(); - tasks.addTask('good', (ctx) => true); + tasks.addSync('good', (ctx) => true); tasks.freeze(); final runner = new TestRunner(tasks, []); @@ -87,7 +87,7 @@ class SyncTests { Action1> completeHandler) { final name = 'task_name'; final tasks = new BaseConfig(); - tasks.addTask(name, task); + tasks.addSync(name, task); tasks.freeze(); final runner = new TestRunner(tasks, [name]); diff --git a/test/hop/task_list_tests.dart b/test/hop/task_list_tests.dart index 2c476f27..1f2f1c25 100644 --- a/test/hop/task_list_tests.dart +++ b/test/hop/task_list_tests.dart @@ -4,9 +4,9 @@ class TaskListTests { static run() { test('dupe names are bad', () { final tasks = new BaseConfig(); - tasks.addTask('task', (ctx) => true); + tasks.addSync('task', (ctx) => true); - expect(() => tasks.addTask('task', (ctx) => true), throwsArgumentError); + expect(() => tasks.addSync('task', (ctx) => true), throwsArgumentError); }); test('reject bad task names', () { @@ -14,7 +14,7 @@ class TaskListTests { final goodNames = const['a','aa','a_','a1','a_b','a_cool_test1_']; for(final n in goodNames) { - tasks.addTask(n, (ctx) => true); + tasks.addSync(n, (ctx) => true); } final badNames = const['', null, ' start white', '1 start num', '\rtest', @@ -22,7 +22,7 @@ class TaskListTests { 'test\r\test', 'UpperCase', 'camelCase']; for(final n in badNames) { - expect(() => tasks.addTask(n, (ctx) => true), throwsArgumentError); + expect(() => tasks.addSync(n, (ctx) => true), throwsArgumentError); } }); @@ -37,7 +37,7 @@ class TaskListTests { expect(() => tasks.freeze(), throws); // cannot add task when frozen - expect(() => tasks.addTask('task', (ctx) => true), throws); + expect(() => tasks.addSync('task', (ctx) => true), throws); }); } } diff --git a/tool/hop_runner.dart b/tool/hop_runner.dart index cdfc6a85..fb96bdbd 100755 --- a/tool/hop_runner.dart +++ b/tool/hop_runner.dart @@ -9,7 +9,7 @@ import '../test/harness_console.dart' as test_console; void main() { _assertKnownPath(); - addTask('hello', (ctx) { + addSyncTask('hello', (ctx) { ctx.fine('Welcome to HOP!'); return true; });