Skip to content

Commit

Permalink
hop: BaseConfig: renaming core add task functions
Browse files Browse the repository at this point in the history
  • Loading branch information
kevmoo committed Nov 24, 2012
1 parent 57f92f8 commit 8e5b9e2
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions lib/hop.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ void runHopCore() {
});
}

void addTask(String name, Func1<TaskContext, bool> execFunc) {
_sharedConfig.addTask(name, execFunc);
void addSyncTask(String name, Func1<TaskContext, bool> execFunc) {
_sharedConfig.addSync(name, execFunc);
}

void addAsyncTask(String name, TaskDefinition execFuture) {
_sharedConfig.addTaskAsync(name, execFuture);
_sharedConfig.addAsync(name, execFuture);
}
4 changes: 2 additions & 2 deletions lib/src/hop/base_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ class BaseConfig {
return _tasks[taskName];
}

void addTask(String name, Func1<TaskContext, bool> func) {
void addSync(String name, Func1<TaskContext, bool> 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));
}

Expand Down
2 changes: 1 addition & 1 deletion test/hop/async_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AsyncTests {
Action1<Future<bool>> 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]);
Expand Down
6 changes: 3 additions & 3 deletions test/hop/sync_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand All @@ -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, []);
Expand All @@ -87,7 +87,7 @@ class SyncTests {
Action1<Future<bool>> 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]);
Expand Down
10 changes: 5 additions & 5 deletions test/hop/task_list_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@ 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', () {
final tasks = new BaseConfig();
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',
'end_white ', 'contains white', 'contains\$bad',
'test\r\test', 'UpperCase', 'camelCase'];

for(final n in badNames) {
expect(() => tasks.addTask(n, (ctx) => true), throwsArgumentError);
expect(() => tasks.addSync(n, (ctx) => true), throwsArgumentError);
}
});

Expand All @@ -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);
});
}
}
2 changes: 1 addition & 1 deletion tool/hop_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down

0 comments on commit 8e5b9e2

Please sign in to comment.