Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Packfile: helper function to add oplibs

  • Loading branch information...
commit 1e2beb978d4559caf3cfeb628b4c067a5ba9efaf 1 parent e062fa1
@Benabik Benabik authored
Showing with 32 additions and 0 deletions.
  1. +11 −0 src/PACT/Packfile.winxed
  2. +21 −0 t/01-packfile/01-packfile.t
View
11 src/PACT/Packfile.winxed
@@ -39,6 +39,17 @@ class PACT.Packfile {
self.uuid = uuid;
}
+ function add_oplib(var name) {
+ if (exists self.oplibs[name])
+ return;
+
+ var oplib = new 'OpLib'(name);
+ if (oplib == null)
+ die("Couldn't get oplib '"+name+"'");
+
+ self.oplibs[name] = oplib;
+ }
+
function __dump(var dumper, string label) {
:(string indent, string subindent) = dumper.newIndent();
say('{');
View
21 t/01-packfile/01-packfile.t
@@ -39,6 +39,27 @@ class PackfileTest {
assert.equal(1, pf.uuid_type);
assert.equal(md5, pf.uuid);
}
+
+ // Test that core_ops is loaded by default
+ function test_oplibs_core() {
+ var assert = self.assert;
+ :PACT.Packfile pf();
+ assert.exists_keyed_str(pf.oplibs, 'core_ops');
+ assert.instance_of(pf.oplibs['core_ops'], 'OpLib');
+ }
+
+ function test_oplibs_math() {
+ var assert = self.assert;
+ string math = 'math_ops';
+ loadlib(math);
+ :PACT.Packfile pf();
+ assert.not_exists_keyed_str(pf.oplibs, math);
+ assert.throws_nothing(function () {
+ pf.add_oplib(math);
+ });
+ assert.exists_keyed_str(pf.oplibs, math);
+ assert.instance_of(pf.oplibs[math], 'OpLib');
+ }
}
# vim: ft=winxed
Please sign in to comment.
Something went wrong with that request. Please try again.