Skip to content

Commit

Permalink
Add basic tests and implementation for reloading use of modules
Browse files Browse the repository at this point in the history
  • Loading branch information
olabini committed Mar 15, 2010
1 parent 5fcd0b3 commit cf95dbf
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/builtin/O05_misc.ik
Expand Up @@ -35,3 +35,6 @@ DefaultBehavior FlowControl sap = dmacro(
self
)

cell(:use) reload = method("will take the same kind of arguments as use, but will make sure that the code will be reloaded every time called.",
filename,
use(filename))
1 change: 1 addition & 0 deletions test/_test2/reload_loadx.ik
@@ -0,0 +1 @@
reload_loadx_loaded = 42
40 changes: 39 additions & 1 deletion test/default_behavior_use_spec.ik
Expand Up @@ -34,8 +34,46 @@ describe(DefaultBehavior,
Ground fooHasBeenLoaded should == 42
)

it("should raise exception if it can't find something",
it("should signal a condition if it can't find something",
fn(use("blarg")) should signal(Condition Error Load)
)

it("should just return a use object if called without arguments",
cell(:use) should == use()
)

describe("reload",
it("should take an absolute file name",
result = use reload(System currentDirectory + "/_test2/reload_loadx")
result should be true
reload_loadx_loaded should == 42
)

it("should take a file in the same directory",
result = use reload("test/reload1")
result should be true
reload_val should == 42
)

it("should take a file in the same directory with an explicit suffix",
result = use reload("test/reload2.ik")
result should be true
reload_val2 should == 42
)

it("should search the added load paths",
System loadPath << "test/sub_load"
use reload("refoo1")
Ground refooHasBeenLoaded should == 42
)

it("should signal a condition if it can't find something",
fn(use reload("blarg")) should signal(Condition Error Load)
)

it("should be possible to load something that has been loaded by use")
it("should be possible to load something that has been loaded by reload before")
it("should be possible to load something that hasn't been loaded before")
)
)
)
1 change: 1 addition & 0 deletions test/reload1.ik
@@ -0,0 +1 @@
Ground reload_val = 42
1 change: 1 addition & 0 deletions test/reload2.ik
@@ -0,0 +1 @@
Ground reload_val2 = 42
3 changes: 3 additions & 0 deletions test/sub_load/refoo1.ik
@@ -0,0 +1,3 @@


Ground refooHasBeenLoaded = 42

0 comments on commit cf95dbf

Please sign in to comment.