Nasal Unit Testing Framework: Difference between revisions

Jump to navigation Jump to search
m
→‎Wrapping dependencies: testing sanitize()
m (Fill in the sanitize function (you can remove the security if you want). Also, it is okay for getprop to return nil for non-existent properties.)
m (→‎Wrapping dependencies: testing sanitize())
Line 117: Line 117:
var setprop = func(p, value) tree[ sanitize(p) ] = value;
var setprop = func(p, value) tree[ sanitize(p) ] = value;
var getprop = func(p) return tree[ sanitize(p) ];
var getprop = func(p) return tree[ sanitize(p) ];
# some tests:
var path = ["/foo/bar", "/foo[0]/bar[0]","/foo[0]/bar[0]/", "/foo/bar[0]","/foo[0]/bar/","/foo[0]/bar/"]
var value = "MyUniqueValue";
setprop(path, value);
foreach(var p; path)
  if (p != value) die("sanitize() implementation is broken");
print("sanitize() looks good!\n");


# init your tree:
# init your tree:

Navigation menu