wheat-cvs Mailing List for Wheat
Status: Pre-Alpha
Brought to you by:
mark_lentczner
You can subscribe to this list here.
2005 |
Jan
(152) |
Feb
(248) |
Mar
(69) |
Apr
(27) |
May
(3) |
Jun
(12) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
---|
From: Mark L. <mar...@us...> - 2005-06-23 06:43:08
|
Update of /cvsroot/wheat/r1/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22462/util Modified Files: test.h Log Message: Changes to appease gcc4.0 Index: test.h =================================================================== RCS file: /cvsroot/wheat/r1/util/test.h,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- test.h 20 Apr 2005 00:28:35 -0000 1.15 +++ test.h 23 Jun 2005 06:42:58 -0000 1.16 @@ -115,7 +115,7 @@ const char* needleExpr, string needle, const char* haystackExpr, string haystack) { - if (pt::pos(needle, haystack) < 0) + if (::pt::pos(needle, haystack) < 0) fail_contains(loc, needle, haystack); else pass(loc); @@ -133,44 +133,44 @@ extern TestGroupList& registry(); #define TEST(group, name) \ - struct Test_##group##_##name : public pt::test { \ - Test_##group##_##name() : pt::test(pt::registry(), #group, #name) { } \ + struct Test_##group##_##name : public ::pt::test { \ + Test_##group##_##name() : ::pt::test(::pt::registry(), #group, #name) { } \ void run(); \ } test_##group##_##name; \ void Test_##group##_##name::run() -#define HERE pt::testlocation(__FILE__, __LINE__, _called_from) -#define WHERE const pt::testlocation& _called_from +#define HERE ::pt::testlocation(__FILE__, __LINE__, _called_from) +#define WHERE const ::pt::testlocation& _called_from #define THERE _called_from #define PASS() \ - pt::test::pass(HERE) + ::pt::test::pass(HERE) #define FAIL(message) \ - pt::test::fail(HERE, message) + ::pt::test::fail(HERE, message) #define SKIP() \ - pt::test::skip(HERE) + ::pt::test::skip(HERE) #define CHECK(cond) \ - pt::test::check(HERE, #cond, cond) + ::pt::test::check(HERE, #cond, cond) #define CHECK_MSG(cond, message) \ - pt::test::check(HERE, message, cond) + ::pt::test::check(HERE, message, cond) #define CHECK_SAME(v, e) \ - pt::test::check_same(HERE, #v, v, #e, e) + ::pt::test::check_same(HERE, #v, v, #e, e) #define CHECK_CONTAINS(needle, haystack) \ - pt::test::check_contains(HERE, #needle, needle, #haystack, haystack) + ::pt::test::check_contains(HERE, #needle, needle, #haystack, haystack) #define CHECK_VALID(ptr) \ CHECK((ptr) != 0) -extern bool pt::runAll( +extern bool runAll( outstm& out, TestGroupList& tests, bool reportPerGroup, bool stopOnFailingGroup); |
From: Mark L. <mar...@us...> - 2005-06-23 06:43:08
|
Update of /cvsroot/wheat/r1/wheat In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22462/wheat Modified Files: fileutil.cpp Log Message: Changes to appease gcc4.0 Index: fileutil.cpp =================================================================== RCS file: /cvsroot/wheat/r1/wheat/fileutil.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- fileutil.cpp 18 Feb 2005 16:10:40 -0000 1.8 +++ fileutil.cpp 23 Jun 2005 06:42:59 -0000 1.9 @@ -160,7 +160,7 @@ return st.st_mtime; } - struct { + struct FileState { pt::string configDirPath; pt::string configStoragePath; } fileState; |
From: Mark L. <mar...@us...> - 2005-06-23 06:43:07
|
Update of /cvsroot/wheat/r1/ptypes/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22462/ptypes/include Modified Files: pinet.h Log Message: Changes to appease gcc4.0 Index: pinet.h =================================================================== RCS file: /cvsroot/wheat/r1/ptypes/include/pinet.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- pinet.h 13 Apr 2004 16:54:50 -0000 1.3 +++ pinet.h 23 Jun 2005 06:42:57 -0000 1.4 @@ -117,7 +117,7 @@ #endif -#if defined(__DARWIN__) || defined(WIN32) +#if (defined(__DARWIN__) && !defined(_SOCKLEN_T)) || defined(WIN32) typedef int psocklen; #else typedef socklen_t psocklen; |
From: Kragen S. <kr...@us...> - 2005-06-07 22:34:05
|
Update of /cvsroot/wheat/r1/root/applications In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6817/root/applications Modified Files: blog.ws farm.ws Log Message: Thought I'd committed this yesterday, but apparently there was a network error. Now post-args is a table, not just a /library/base/object. Consequently it should now be safe to handle form posts with form field names like "absolute-path" and "member". Added comments on untested methods. Blog edit doesn't work, but I don't think that's a result of these changes. Index: blog.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/applications/blog.ws,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- blog.ws 30 Apr 2005 04:42:33 -0000 1.31 +++ blog.ws 7 Jun 2005 22:33:49 -0000 1.32 @@ -79,13 +79,13 @@ -- public -- new(blog, dest): { return {:self: blog: \blog; dest: \\dest; }; } submit(request: r, post-args: args): { - if (~ args.account.is-empty() - ... && ~ args.password.is-empty() - ... && #blog.users.has-key(args.account) - ... && #blog.users[args.account].password == args.password) + if (~ args["account"].is-empty() + ... && ~ args["password"].is-empty() + ... && #blog.users.has-key(args["account"]) + ... && #blog.users[args["account"]].password == args["password"]) { r.session("logged-in") := true; - r.session("account") := args.account; + r.session("account") := args["account"]; } else { return !!!("login failed"); @@ -118,17 +118,18 @@ add-operation: { -- instance -- blog: ??? - args: { } + args: { } `` XXX this seems useless. What's it for? -- public -- new(blog): { return {:self: blog: \blog; }; } template(): { return \#blog.templates.'editadd.html'; } submit(post-args: args, request: r): { - if (args.title.is-empty() - ... || args.author.is-empty() - ... || args.story.is-empty() - ... || args.title == #default-title - ... || args.author == #default-author - ... || args.story == #default-story) + `` XXX no test coverage for this logic: + if (args["title"].is-empty() + ... || args["author"].is-empty() + ... || args["story"].is-empty() + ... || args["title"] == #default-title + ... || args["author"] == #default-author + ... || args["story"] == #default-story) { #args := args; return #render(request: r); @@ -136,9 +137,9 @@ newEntry := { `` :'../blog-entry': -- relative paths don't work ... :'/applications/blog/blog-entry': - title: args.title; - author: args.author; - full-story: args.story; + title: args["title"]; + author: args["author"]; + full-story: args["story"]; date: $/library/base/date.today(); }; @@ -386,14 +387,15 @@ return self; } submit(request: r, post-args: args): { - if (args.title.is-empty() - ... || args.story.is-empty()) + `` XXX no test coverage for this method + if (args["title"].is-empty() + ... || args["story"].is-empty()) { return #render(request: r); } - #entry.title := args.title; - #entry.full-story := args.full-story; + #entry.title := args["title"]; + #entry.full-story := args["full-story"]; return $/library/render.redirect(\#entry, request: \r); } @@ -714,24 +716,24 @@ } login-as-alpha(blog, request): { - args := { - account: "alpha" - password: "aaa" - login: "Login" - }; - response := blog.login.submit(request: \request, post-args: args); - #assert-equals("see-other", response.type); - #assert-equals("http://example.com/blog", response.location); + args := $/library/base/table.from-array([ + "account", "alpha", + "password", "aaa", + "login", "Login", + ...]) + response := blog.login.submit(request: \request, post-args: args) + #assert-equals("see-other", response.type) + #assert-equals("http://example.com/blog", response.location) } test-add-entry(): { blog := \#sample-blog-1; request := #sample-request; - post-args := { - title: "City-Wide Garage Sale" - author: "Carol Councilmember" - story: "There will be a city-wide garage sale this Saturday..." - }; + post-args := $/library/base/table.from-array([ + "title", "City-Wide Garage Sale", + "author", "Carol Councilmember", + "story", "There will be a city-wide garage sale this Saturday...", + ...]) response := blog.add.submit(request: \request, post-args: post-args); #assert-equals("see-other", response.type); #assert-equals("http://example.com/blog/entries/3", Index: farm.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/applications/farm.ws,v retrieving revision 1.65 retrieving revision 1.66 diff -u -d -r1.65 -r1.66 --- farm.ws 30 Apr 2005 04:42:34 -0000 1.65 +++ farm.ws 7 Jun 2005 22:33:49 -0000 1.66 @@ -58,7 +58,8 @@ -- public -- submit(post-args: p, request: r): { - if (p.do-create-project) { + `` XXX this case is untested + if (p["do-create-project"]) { return #do-create-project(post-args: p, request: r) } return $/library/render.redirect(\self, request: \r) @@ -66,7 +67,8 @@ -- private -- do-create-project(post-args: p, request: r): { - (result := #create-project(p.name))! + `` XXX this is not tested + (result := #create-project(p["name"]))! if (result!) { return $/library/render.expand( subject: {:self: @@ -78,7 +80,7 @@ } return $/library/render.redirect( - \$/development.member(p.name), + \$/development.member(p["name"]), request: \r) } @@ -217,10 +219,10 @@ -- public -- submit(post-args: p, request: r): { - if (p.do-compile) { #do-save(p); #do-compile() } - else if (p.do-save) { #do-save(p) } - else if (p.do-instantiate) { return #do-instantiate(p, \r) } - else { return #render(request: \r) } + if (p["do-compile"]) { #do-save(p); #do-compile() } + else if (p["do-save"]) { #do-save(p) } + else if (p["do-instantiate"]) { return #do-instantiate(p, \r) } + else { return #render(request: \r) } return $/library/render.redirect(\self, request: \r) } @@ -233,8 +235,8 @@ -- private -- do-save(args): { - #source := args.source.as-path() - #target := args.target.as-path() + #source := args["source"].as-path() + #target := args["target"].as-path() #compilation-state.value := "never" #test-results := ??? #compile-result := ??? @@ -271,8 +273,8 @@ } do-instantiate(args, req): { - p := args.proto.as-path - t := args.target.as-path + p := args["proto"].as-path + t := args["target"].as-path (r := ($..).instantiator.instantiate( prototype: \p.dereference, @@ -619,11 +621,11 @@ test-bad-compile-with-location-and-redirect(): { #sample.init(\#sample.source-text-bad-compile) result := #sample.submit( - post-args: { - do-compile: "Compile" - source: #sample.source.as-string - target: #sample.target.as-string - }, + post-args: $/library/base/table.from-array([ + "do-compile", "Compile", + "source", #sample.source.as-string, + "target", #sample.target.as-string, + ...]), request: #sample-request ) @@ -655,7 +657,7 @@ #sample.init(\#sample.source-text-good) #sample.do-compile() page := #sample.submit( - post-args: { }, + post-args: $/library/base/table.from-array([]), request: #sample-request ) #assert-has-all-substrings( @@ -675,7 +677,7 @@ #sample.init(\#sample.source-text-bad-test) #sample.do-compile() page := #sample.submit( - post-args: { }, + post-args: $/library/base/table.from-array([]), request: #sample-request ) #assert-has-all-substrings(#result-substrings-for-failing-test, page) @@ -698,7 +700,7 @@ #sample.init(\#sample.source-text-empty-tests) #sample.do-compile() page := #sample.submit( - post-args: { }, + post-args: $/library/base/table.from-array([]), request: #sample-request ) #assert-has-all-substrings(#result-substrings-for-no-tests, page) @@ -950,11 +952,11 @@ #sample.init(\#sample.source-text-good) response := #sample.submit( - post-args: { - do-instantiate: "Create" - proto: prototype - target: target - }, + post-args: $/library/base/table.from-array([ + "do-instantiate", "Create", + "proto", prototype, + "target", target, + ...]), request: #sample-request ) @@ -973,11 +975,11 @@ #sample.init(\#sample.source-text-bad-test) target := (#sample.absolute-path + "another-built-module").as-string #sample.submit( - post-args: { - do-save: "Save" - source: #source-text-good-path - target: target - }, + post-args: $/library/base/table.from-array([ + "do-save", "Save", + "source", #source-text-good-path, + "target", target, + ...]), request: #sample-request ) #assert-equals(#source-text-good-path, #sample.source.as-string()) @@ -990,11 +992,11 @@ test-compile-saves(): { #sample.init(\#sample.source-text-bad-test) #sample.submit( - post-args: { - do-compile: "Compile" - source: #source-text-good-path - target: #sample.target.as-string - }, + post-args: $/library/base/table.from-array([ + "do-compile", "Compile", + "source", #source-text-good-path, + "target", #sample.target.as-string, + ...]), request: #sample-request ) #assert-equals(#source-text-good-path, #sample.source.as-string) |
From: Kragen S. <kr...@us...> - 2005-06-07 22:33:59
|
Update of /cvsroot/wheat/r1/web-dev/source/graffiti In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6817/web-dev/source/graffiti Modified Files: graffiti.ws Log Message: Thought I'd committed this yesterday, but apparently there was a network error. Now post-args is a table, not just a /library/base/object. Consequently it should now be safe to handle form posts with form field names like "absolute-path" and "member". Added comments on untested methods. Blog edit doesn't work, but I don't think that's a result of these changes. Index: graffiti.ws =================================================================== RCS file: /cvsroot/wheat/r1/web-dev/source/graffiti/graffiti.ws,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- graffiti.ws 3 Jun 2005 23:20:11 -0000 1.2 +++ graffiti.ws 7 Jun 2005 22:33:50 -0000 1.3 @@ -17,7 +17,7 @@ "For a good time call 867-5309"] } submit(post-args:p, request:r): { - #add(p.new-graffito) + #add(p["new-graffito"]) return $/library/render.redirect(\self, request:r) } template: @@ -85,7 +85,7 @@ <ul id="theWall"> <li tt:name="wall-graffiti"><tt:span tt:name="graffito">Graffito</tt:span></li> </ul> - <form method="POST" onsubmit="invokeAction('hello', 'theWall', {'new-graffito': this['new-graffito'].value}); return false"> + <form method="POST" onsubmit="invokeAction('hello', 'theWall', {'new-graffito': this['new-graffito'].value}); document.body.innerHTML += 'glork'; return false"> <input name="new-graffito" /> <input name="op" value="add" type="submit" /> </form> @@ -163,11 +163,11 @@ test-adding-web(): { wall := \#create-wall what := wall.submit( - post-args:{ - op: "add" - new-graffito: "Hello" - }, - request:#sample-request) + post-args: $/library/base/table.from-array([ + "op", "add", + "new-graffito", "Hello", + ...]), + request: #sample-request) #assert-equals("see-other", what.type) #assert-equals($/library/render.url(\wall, request:#sample-request), what.location) html := wall.render() |
From: Kragen S. <kr...@us...> - 2005-06-07 22:33:58
|
Update of /cvsroot/wheat/r1/web-dev/source/animal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6817/web-dev/source/animal Modified Files: animal.ws Log Message: Thought I'd committed this yesterday, but apparently there was a network error. Now post-args is a table, not just a /library/base/object. Consequently it should now be safe to handle form posts with form field names like "absolute-path" and "member". Added comments on untested methods. Blog edit doesn't work, but I don't think that's a result of these changes. Index: animal.ws =================================================================== RCS file: /cvsroot/wheat/r1/web-dev/source/animal/animal.ws,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- animal.ws 15 Feb 2005 05:59:54 -0000 1.5 +++ animal.ws 7 Jun 2005 22:33:50 -0000 1.6 @@ -89,11 +89,12 @@ add(a, b, c): { self.container.add(a, b, c); } submit(post-args: args, request: req): { + `` XXX this is not tested last-node := \self.container; last-node.add( - args.new-animal-name, - args.distinguishing-question, - args.answer); + args["new-animal-name"], + args["distinguishing-question"], + args["answer"]); return last-node.game-over.render(request: req); } } |
From: Kragen S. <kr...@us...> - 2005-06-07 22:33:58
|
Update of /cvsroot/wheat/r1/server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6817/server Modified Files: mod_render-test.cpp mod_render.cpp Log Message: Thought I'd committed this yesterday, but apparently there was a network error. Now post-args is a table, not just a /library/base/object. Consequently it should now be safe to handle form posts with form field names like "absolute-path" and "member". Added comments on untested methods. Blog edit doesn't work, but I don't think that's a result of these changes. Index: mod_render.cpp =================================================================== RCS file: /cvsroot/wheat/r1/server/mod_render.cpp,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- mod_render.cpp 5 Feb 2005 07:22:42 -0000 1.30 +++ mod_render.cpp 7 Jun 2005 22:33:50 -0000 1.31 @@ -323,14 +323,22 @@ m.setUp(f, obj, request); Local postArgs(f); - postArgs = Object(); + postArgs = Object(Path("/library/base/table")); int nArgs = postVars.countVars(); for (int i = 0; i < nArgs; ++i) { - pt::string argName = postVars.getVar(i); - pt::string argValue = postVars.get(argName); + pt::string argNameAsString = postVars.getVar(i); + String argName(argNameAsString); + True trueValue; + String argValue(postVars.get(argNameAsString)); + pt::string assign = "assign"; + pt::string value = "value"; - postArgs.send("add-member", String(argName), String(argValue)); + postArgs.send("[]", + SendArgPos, &argName, + SendArgKey, &assign, &trueValue, + SendArgKey, &value, &argValue, + SendArgEnd); } Local result(f); Index: mod_render-test.cpp =================================================================== RCS file: /cvsroot/wheat/r1/server/mod_render-test.cpp,v retrieving revision 1.45 retrieving revision 1.46 diff -u -d -r1.45 -r1.46 --- mod_render-test.cpp 8 Mar 2005 06:09:52 -0000 1.45 +++ mod_render-test.cpp 7 Jun 2005 22:33:49 -0000 1.46 @@ -251,11 +251,11 @@ Argument args(f, "post-args"); Local x(f); - x = args.send("x"); + x = args.send("[]", String("x")); self.send("thing").assign("x", x.copy()); Local y(f); - y = args.send("y"); + y = args.send("[]", String("y")); self.send("thing").assign("y", y.copy()); return Return(f, String("submitted!")); |
From: Kragen S. <kr...@us...> - 2005-06-07 22:33:58
|
Update of /cvsroot/wheat/r1/root/library In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6817/root/library Modified Files: base.ws Log Message: Thought I'd committed this yesterday, but apparently there was a network error. Now post-args is a table, not just a /library/base/object. Consequently it should now be safe to handle form posts with form field names like "absolute-path" and "member". Added comments on untested methods. Blog edit doesn't work, but I don't think that's a result of these changes. Index: base.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/library/base.ws,v retrieving revision 1.60 retrieving revision 1.61 diff -u -d -r1.60 -r1.61 --- base.ws 5 May 2005 17:42:25 -0000 1.60 +++ base.ws 7 Jun 2005 22:33:49 -0000 1.61 @@ -426,8 +426,19 @@ value-at(i): { return \#entries[i].value } clear(): { #entries := ???; } + + from-array(args): { + rv := {:'/library/base/table':} + ii := 0 + while (ii < args.size) { + rv[args[ii]] := args[ii + 1] + ii += 2 + } + return rv + } } + file: { -- public -- mime-type: {:'/library/base/primitive':} @@ -457,6 +468,15 @@ #assert-equals(false, t["bob"]!); } + test-table-some-more(): { + t := ($..).table.from-array(["bob", 3, "mary", 44, + "as-string", 55, "member", 666]) + #assert-equals(3, t["bob"]) + #assert-equals(44, t["mary"]) + #assert-equals(55, t["as-string"]) + #assert-equals(666, t["member"]) + } + test-string-as-path(): { path-string := "/library/wheatunit/test-case"; path := path-string.as-path(); |
From: Mark L. <mar...@us...> - 2005-06-03 23:21:34
|
Update of /cvsroot/wheat/r1/wheat In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21890/wheat Modified Files: memobject.cpp Log Message: Slight improvement to the prototype code: if absolute already, just use it Index: memobject.cpp =================================================================== RCS file: /cvsroot/wheat/r1/wheat/memobject.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- memobject.cpp 3 Jun 2005 22:54:14 -0000 1.18 +++ memobject.cpp 3 Jun 2005 23:21:24 -0000 1.19 @@ -362,6 +362,9 @@ if (prototype.isEmpty()) { m->prototype = standardPrototype(TypeObject); } + else if (prototype.isAbsolute()) { + m->prototype = prototype; + } else { Path base = NameSpace::pathTo(p.container()); Path absolute(base, prototype); |
From: Kragen S. <kr...@us...> - 2005-06-03 23:20:21
|
Update of /cvsroot/wheat/r1/web-dev/source/graffiti In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21208/web-dev/source/graffiti Modified Files: graffiti.ws Log Message: Tiny fixlets. Playing with XMLHttpRequest. Index: graffiti.ws =================================================================== RCS file: /cvsroot/wheat/r1/web-dev/source/graffiti/graffiti.ws,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- graffiti.ws 9 Apr 2005 03:22:39 -0000 1.1 +++ graffiti.ws 3 Jun 2005 23:20:11 -0000 1.2 @@ -17,7 +17,6 @@ "For a good time call 867-5309"] } submit(post-args:p, request:r): { - ``p.low-level-debug #add(p.new-graffito) return $/library/render.redirect(\self, request:r) } @@ -46,22 +45,24 @@ var request = createRequest() request.onreadystatechange = function() { if (request.readyState == COMPLETED) { - document.open() - document.write(request.responseText) - document.close() - -/* try { - var oldNode = document.getElementById(whatId) - oldNode.id = '' - var newNodeInNewDocument = request.responseXML.getElementById(whatId) - alert(newNodeInNewDocument) - var newNode = document.importNode(newNodeInNewDocument, true) - oldNode.parentNode.replaceChild(newNode, oldNode) - alert(request.responseText) - } catch (e) { - window.fuckedup = e + var newDocument = document.createElement('div') + newDocument.innerHTML = request.responseText + // iterate nodes looking for ones marked with tt:?? + var evaluator = document.evaluate('.//*', newDocument, null, null, null) + var matches = {} + while (var node = evaluator.iterateNext()) { + if (var name = node.getAttribute('id')) { + matches[name] = node + } + } + var evaluator = document.evaluate('.//*', document, null, null, null) + while (var node = evaluator.iterateNext()) { + if (var name = node.getAttribute('id')) { + if (matches[name]) { + node.parentNode.replaceChild(node, matches[name]) + } + } } -*/ } } request.open('POST', 'http://localhost:8100/garden/thingy') @@ -73,7 +74,6 @@ '=' + encodeURIComponent(arguments[key])) } - request.overrideMimeType('text/xml') request.send(encoded.join('&')) } @@ -99,9 +99,9 @@ tt-wall-graffiti(): { #start-repeat() i := 0 - g := #subject.wall-graffiti + g := \#subject.wall-graffiti while (i < g.size) { - #expand(subject: g[i], expander: \#graffito-expander) + #expand(subject: \g[i], expander: \#graffito-expander) i += 1 } } |
From: Jim K. <ki...@us...> - 2005-06-03 22:54:23
|
Update of /cvsroot/wheat/r1/wheat In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7291/wheat Modified Files: filemedia.cpp media-test.cpp media.cpp media.hpp memobject-test.cpp memobject.cpp tempmedia.cpp xmlmedia-test.cpp xmlmedia.cpp xmlutil-test.cpp Log Message: Relative paths in prototype now get absolutified when object is created. Mounts now have an initialize method, so XMLMedia reads in the file when we call initialize, not in the constructor (that is, after it is mounted into the tree). Index: xmlmedia-test.cpp =================================================================== RCS file: /cvsroot/wheat/r1/wheat/xmlmedia-test.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- xmlmedia-test.cpp 18 Feb 2005 16:10:43 -0000 1.15 +++ xmlmedia-test.cpp 3 Jun 2005 22:54:14 -0000 1.16 @@ -7,6 +7,9 @@ */ #include "xmlmedia.hpp" +#include "reference.hpp" +#include "frame.hpp" +#include "value.hpp" #include "test.h" #include "testutil.hpp" @@ -293,6 +296,33 @@ checkpart(HERE, bottom, 100, true, "water"); } +TEST(xmlmedia, relativePrototype) +{ + static const char xml[] = + "<?xml version='1.0' encoding='UTF-8'?>" + "<wheatobject version='1.0'>" + "<object>" + "<object name='stream'/>" + "<object name='encrypted-stream' prototype='stream'/>" + "</object>" + "</wheatobject>"; + + /* For now, just test that TestUtil::Setup does things right. + But of course we might want a test that more closely resembles + what happens for xmlmedia mentioned in the config file. */ + TestUtil::Setup setup("/test/xml", xml); + + Thread t; + Frame& f = t.topFrame(); + + Local copy(f); + copy = setup.topLink(); + copy = copy.send("encrypted-stream"); + + CHECK_SAME("/test/xml/stream", copy.prototype().asString()); +} + + /* things to test: empty object and array Index: filemedia.cpp =================================================================== RCS file: /cvsroot/wheat/r1/wheat/filemedia.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- filemedia.cpp 7 Feb 2005 05:05:24 -0000 1.9 +++ filemedia.cpp 3 Jun 2005 22:54:14 -0000 1.10 @@ -399,6 +399,8 @@ { public: FileMount(const FileUtil::HostPath& rootPath); + + virtual void initialize(); virtual ObjectPointer root(); virtual void persist(); @@ -412,6 +414,10 @@ FileMount::FileMount(const FileUtil::HostPath& rootPath) : mObjectManager(*this, rootPath) { } + + void + FileMount::initialize() + { } ObjectPointer FileMount::root() Index: xmlmedia.cpp =================================================================== RCS file: /cvsroot/wheat/r1/wheat/xmlmedia.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- xmlmedia.cpp 18 Feb 2005 16:10:43 -0000 1.11 +++ xmlmedia.cpp 3 Jun 2005 22:54:14 -0000 1.12 @@ -45,6 +45,8 @@ public: XMLMount(ref_ptr<XMLStorage> storage, bool readOnly, bool persistent); ~XMLMount(); + + virtual void initialize(); virtual ObjectPointer root(); virtual void persist(); @@ -64,7 +66,11 @@ mReadOnly(readOnly), mPersistent(persistent) { mReadOnly |= mStorage->isReadOnly(); - + } + + void + XMLMount::initialize() + { ref_ptr<XMLStorageNode> firstNode = mStorage->readStorage(); XMLTaskStack taskStack; Index: media-test.cpp =================================================================== RCS file: /cvsroot/wheat/r1/wheat/media-test.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- media-test.cpp 18 Feb 2005 16:10:40 -0000 1.12 +++ media-test.cpp 3 Jun 2005 22:54:14 -0000 1.13 @@ -41,6 +41,7 @@ public: TestMount(const pt::string&); + virtual void initialize(); virtual ObjectPointer root(); virtual void persist(); @@ -100,6 +101,10 @@ : mObjectManager(str, *this) { } + void + TestMount::initialize() + { } + ObjectPointer TestMount::root() { Index: memobject.cpp =================================================================== RCS file: /cvsroot/wheat/r1/wheat/memobject.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- memobject.cpp 18 Feb 2005 16:10:40 -0000 1.17 +++ memobject.cpp 3 Jun 2005 22:54:14 -0000 1.18 @@ -358,8 +358,16 @@ clearValue(v); MemoryObject* m = new MemoryObject; - m->prototype = - prototype.isEmpty() ? standardPrototype(TypeObject) : prototype; + + if (prototype.isEmpty()) { + m->prototype = standardPrototype(TypeObject); + } + else { + Path base = NameSpace::pathTo(p.container()); + Path absolute(base, prototype); + m->prototype = absolute; + } + m->capacity = 0; m->keySize = 0; m->arraySize = 0; Index: media.cpp =================================================================== RCS file: /cvsroot/wheat/r1/wheat/media.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- media.cpp 18 Feb 2005 16:10:40 -0000 1.10 +++ media.cpp 3 Jun 2005 22:54:14 -0000 1.11 @@ -252,10 +252,13 @@ mountList.add(node); - while (node) { - ++node->subMounts; - node = node->container; + MountNode* walk = node; + while (walk) { + ++walk->subMounts; + walk = walk->container; } + + node->mount->initialize(); } Index: memobject-test.cpp =================================================================== RCS file: /cvsroot/wheat/r1/wheat/memobject-test.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- memobject-test.cpp 18 Feb 2005 16:10:40 -0000 1.6 +++ memobject-test.cpp 3 Jun 2005 22:54:14 -0000 1.7 @@ -19,6 +19,8 @@ { public: SimpleMount() : mManager(*this) { } + + virtual void initialize() { } virtual ObjectPointer root() { return mManager.root(); } virtual void persist() { mManager.clearModified(); } Index: xmlutil-test.cpp =================================================================== RCS file: /cvsroot/wheat/r1/wheat/xmlutil-test.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- xmlutil-test.cpp 18 Feb 2005 16:10:43 -0000 1.17 +++ xmlutil-test.cpp 3 Jun 2005 22:54:14 -0000 1.18 @@ -293,10 +293,12 @@ "<wheatobject version=\"1.0\">\n" " <object prototype=\"/test/xmlutil/top\">\n" " <object name=\"a\" prototype=\"/test/xmlutil/foo\">\n" - " <object name=\"x\" mode=\"rw------\" prototype=\"../xray\">\n" + " <object name=\"x\" mode=\"rw------\" prototype=\"/test/xmlutil/writer/xray\">\n" " </object>\n" " </object>\n" - " <array name=\"b\" prototype=\"../../bar\">\n" + // probably would rather have: + //" <array name=\"b\" prototype=\"../../bar\">\n" + " <array name=\"b\" prototype=\"/test/bar\">\n" " <object prototype=\"/test/xmlutil/zero\">\n" " </object>\n" " <object prototype=\"/test/xmlutil/one\">\n" Index: tempmedia.cpp =================================================================== RCS file: /cvsroot/wheat/r1/wheat/tempmedia.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- tempmedia.cpp 18 Feb 2005 16:10:43 -0000 1.6 +++ tempmedia.cpp 3 Jun 2005 22:54:14 -0000 1.7 @@ -19,6 +19,8 @@ { public: TempMount(); + + virtual void initialize(); virtual ObjectPointer root(); virtual void persist(); @@ -32,6 +34,10 @@ TempMount::TempMount() : mObjectManager(*this) { } + + void + TempMount::initialize() + { } ObjectPointer TempMount::root() Index: media.hpp =================================================================== RCS file: /cvsroot/wheat/r1/wheat/media.hpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- media.hpp 18 Feb 2005 16:10:40 -0000 1.5 +++ media.hpp 3 Jun 2005 22:54:14 -0000 1.6 @@ -47,6 +47,8 @@ virtual ~Mount(); public: + virtual void initialize() = 0; + virtual ObjectPointer root() = 0; virtual void persist() = 0; }; |
From: Jim K. <ki...@us...> - 2005-06-03 22:54:23
|
Update of /cvsroot/wheat/r1/root/library In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7291/root/library Modified Files: compiler.ws Log Message: Relative paths in prototype now get absolutified when object is created. Mounts now have an initialize method, so XMLMedia reads in the file when we call initialize, not in the constructor (that is, after it is mounted into the tree). Index: compiler.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/library/compiler.ws,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- compiler.ws 5 May 2005 17:42:25 -0000 1.1 +++ compiler.ws 3 Jun 2005 22:54:14 -0000 1.2 @@ -71,4 +71,22 @@ #assert-error("system/vm/exception/not-found(++)", error); } + point2d: { x: 5; y: 6 } +`` absolute: { :'/library/compiler/tests/point2d': } + relative: { :point2d: } + + test-prototype(): { + point2d := $point2d.absolute-path.as-string; +`` #assert-equals(point2d, $absolute.prototype().as-string); + #assert-equals(point2d, $relative.prototype().as-string); + copy := $relative; + #assert-equals(point2d, copy.prototype().as-string); + } + + test-inheritance(): { + #assert-equals(5, $relative.x); + copy := $relative; + #assert-equals(5, copy.x); + } + } |
From: Jim K. <ki...@us...> - 2005-05-05 17:42:49
|
Update of /cvsroot/wheat/r1/root/library In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26076/root/library Modified Files: base.ws Added Files: compiler.ws Log Message: Split compiler tests out of base.ws and put them in compiler.ws. --- NEW FILE: compiler.ws --- wheat(version: 1) ``( Tests that go with compiler-test.cpp, but which I'd rather write in wheat (most tests in compiler-test are perhaps candidates). ``) tests: {:'/library/wheatunit/test-case': -- public -- test-unknown-global(): { unknown := $no-such-member; known := $sample-member; `` Why ??? and not error? #assert-equals(???, unknown); if (unknown?) { #fail(); } else { #pass(); } #assert-equals(false, unknown?); if (known?) { #pass(); } else { #fail(); } #assert-equals(true, known?); } -- private -- sample-member: 5; -- public -- test-test-for-unknown(): { unknown-value := ???; known-value := 5; #assert-equals(true, 5?); #assert-equals(true, known-value?); #assert-equals(false, ??? ?); #assert-equals(false, unknown-value?); `` Probably want the error to propagate, so error-value? is `` the error itself. Currently, error is considered known (yuck). (error-value := !!!("bad"))!; #assert-equals(true, error-value?); #assert-equals(true, !!!("also bad") ?); } `` Only problem is, THERE IS NO BREAK STATEMENT! `` (Looking at ScriptCompiler, it would appear that break `` is currently implemented as a noop). test-break(): { i := 0; while (i < 5) { if (i == 1) { break; } i += 1; } #assert-equals(5, i); `` #assert-equals(1, i); } `` The real problem that motivated this test was trying to `` erroneously advance the control variable of a loop with ++i. `` The error check doesn't help, because we never get out of the loop. test-plusplus(): { i := 0; (error := ++i)!; #assert-error("system/vm/exception/not-found(++)", error); } } Index: base.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/library/base.ws,v retrieving revision 1.59 retrieving revision 1.60 diff -u -d -r1.59 -r1.60 --- base.ws 30 Apr 2005 04:42:34 -0000 1.59 +++ base.ws 5 May 2005 17:42:25 -0000 1.60 @@ -989,75 +989,6 @@ model: { :'/library/base/enum': values: ["corolla", "prius", "civic"] } - `` Tests that go with compiler-test.cpp, but which I'd rather write in - `` wheat (most tests in compiler-test are perhaps candidates). - `` Probably we should have a compiler.ws or some such for these to live in. - -- public -- - test-unknown-global(): { - unknown := $/library/base/tests/no-such-member; - known := $/library/base/tests/sample-member; - - `` Why ??? and not error? - #assert-equals(???, unknown); - if (unknown?) { - #fail(); - } else { - #pass(); - } - #assert-equals(false, unknown?); - if (known?) { - #pass(); - } else { - #fail(); - } - #assert-equals(true, known?); - } - -- private -- - sample-member: 5; - - -- public -- - - test-test-for-unknown(): { - unknown-value := ???; - known-value := 5; - #assert-equals(true, 5?); - #assert-equals(true, known-value?); - #assert-equals(false, ??? ?); - #assert-equals(false, unknown-value?); - - `` Probably want the error to propagate, so error-value? is - `` the error itself. Currently, error is considered known (yuck). - (error-value := !!!("bad"))!; - #assert-equals(true, error-value?); - #assert-equals(true, !!!("also bad") ?); - } - - `` Only problem is, THERE IS NO BREAK STATEMENT! - `` (Looking at ScriptCompiler, it would appear that break - `` is currently implemented as a noop). - test-break(): { - i := 0; - while (i < 5) { - if (i == 1) { - break; - } - i += 1; - } - #assert-equals(5, i); -`` #assert-equals(1, i); - } - - `` The real problem that motivated this test was trying to - `` erroneously advance the control variable of a loop with ++i. - `` The error check doesn't help, because we never get out of the loop. - test-plusplus(): { - i := 0; - (error := ++i)!; - #assert-error("system/vm/exception/not-found(++)", error); - } - - `` end compiler-test.cpp-like tests - -- public -- test-path-trail-expander(): { html := $/library/render.expand( |
From: Jim K. <ki...@us...> - 2005-05-05 17:42:49
|
Update of /cvsroot/wheat/r1/web-dev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26076/web-dev Modified Files: config.xml Log Message: Split compiler tests out of base.ws and put them in compiler.ws. Index: config.xml =================================================================== RCS file: /cvsroot/wheat/r1/web-dev/config.xml,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- config.xml 21 Feb 2005 07:40:44 -0000 1.7 +++ config.xml 5 May 2005 17:42:26 -0000 1.8 @@ -99,6 +99,10 @@ <path name="source" ref="/root/library/base.ws" /> </object> <object> + <string name="name">compiler</string> + <path name="source" ref="/root/library/compiler.ws" /> + </object> + <object> <string name="name">render</string> <path name="source" ref="/root/library/render.ws" /> </object> |
From: Jim K. <ki...@us...> - 2005-05-05 17:42:34
|
Update of /cvsroot/wheat/r1/root In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26076/root Modified Files: config-web-test.xml Log Message: Split compiler tests out of base.ws and put them in compiler.ws. Index: config-web-test.xml =================================================================== RCS file: /cvsroot/wheat/r1/root/config-web-test.xml,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- config-web-test.xml 21 Feb 2005 07:40:42 -0000 1.34 +++ config-web-test.xml 5 May 2005 17:42:24 -0000 1.35 @@ -82,6 +82,10 @@ <path name="source" ref="/root/library/base.ws" /> </object> <object> + <string name="name">compiler</string> + <path name="source" ref="/root/library/compiler.ws" /> + </object> + <object> <string name="name">render</string> <path name="source" ref="/root/library/render.ws" /> </object> |
From: Jim K. <ki...@us...> - 2005-04-30 04:42:43
|
Update of /cvsroot/wheat/r1/root/library In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19882/root/library Modified Files: base.ws render.ws wheatunit.ws Log Message: Rename table.has to table.has-key (it isn't analogous in function to array.has). Also in table, rename key-at-index to key-at and value-at-index to value-at. In render, extract method append-subexpansion. In wheatunit, take a small step towards having a failure message be a renderable object rather than a string. Index: wheatunit.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/library/wheatunit.ws,v retrieving revision 1.44 retrieving revision 1.45 diff -u -d -r1.44 -r1.45 --- wheatunit.ws 30 Apr 2005 01:02:49 -0000 1.44 +++ wheatunit.ws 30 Apr 2005 04:42:34 -0000 1.45 @@ -19,25 +19,28 @@ `` called from testutil.cpp skipped: ??? - failure-error: ??? + failure-info: ??? nonerror-message: ??? -- public -- new(method-name, instance, return-value): { if (return-value!) { + failure-info := $/library/wheatunit/error-info.new(return-value!) return { :'/library/wheatunit/result': name: method-name - passed: false; - skipped: false; - failure-error: return-value!; + passed: false + skipped: false + failure-info: failure-info }; } else if (instance.failure-error?) { + failure-info := $/library/wheatunit/error-info.new( + instance.failure-error) return { :'/library/wheatunit/result': - name: method-name; - passed: false; - skipped: instance.skipped; - failure-error: instance.failure-error + name: method-name + passed: false + skipped: instance.skipped + failure-info: failure-info }; } else if (instance.failure.is-string) { @@ -68,18 +71,38 @@ -- public -- `` called from testutil.cpp failure-message(): { - if (#failure-error?) { - return #message-from-error(#failure-error); + if (#failure-info?) { + return #failure-info.message-as-string } else { return #nonerror-message; } } - -- private -- - message-from-error(error-value): { - message := error-value.reason-string(); - trace := error-value.trace-string(); +} + +failure-info: { + -- public -- + message-as-string(): { + return !!!("should implement this in subclass") + } + + `` message-as-html +} + +error-info: { :'/library/wheatunit/failure-info': + + -- instance -- + error-value: ??? + + -- public -- + new(error-value): { + return { :self: error-value: error-value } + } + + message-as-string(): { + message := #error-value.reason-string(); + trace := #error-value.trace-string(); if ( ~ trace.is-empty() ) { message += "\n"; message += trace; @@ -399,7 +422,7 @@ result := #one-result(\#trace-string-in-error); file := "/root/library/wheatunit.ws"; - l := result.failure-error.trace-event(2).start-line; + l := result.failure-info.error-value.trace-event(2).start-line; #assert-equals(false, result.passed); #assert-equals( "warp-drive-failed\n" + Index: render.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/library/render.ws,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- render.ws 30 Apr 2005 01:02:49 -0000 1.38 +++ render.ws 30 Apr 2005 04:42:34 -0000 1.39 @@ -186,7 +186,7 @@ } action(name): { - if (#map.has(name)) { + if (#map.has-key(name)) { return #map[name].action } else { @@ -262,21 +262,17 @@ baddies := [ ] i := 0 while (i < #map.size) { - action := #map.value-at-index(i).action + action := #map.value-at(i).action if (action.matches("unexpanded")) { - baddies.add(#map.key-at-index(i) + ": not expanded") + baddies.add(#map.key-at(i) + ": not expanded") } else if (action.matches("repeated")) { - key := #map.key-at-index(i) - repeats := \\#map.value-at-index(i).repeats + key := #map.key-at(i) + repeats := \\#map.value-at(i).repeats j := 0 while (j < repeats.size) { b := repeats[j].find-unexpanded() - k := 0 - while (k < b.size) { - baddies.add(key + "[" + j + "]/" + b[k]) - k += 1 - } + #append-subexpansion(\baddies, key, j, b) j += 1 } } @@ -329,11 +325,7 @@ j := 0 while (j < count && j < expected.size) { b := #repeat-index(key, j).find-mismatches(expected[j]) - k := 0 - while (k < b.size) { - baddies.add(key + "[" + j + "]/" + b[k]) - k += 1 - } + #append-subexpansion(\baddies, key, j, b) j += 1 } } @@ -342,6 +334,16 @@ return baddies; } + -- private -- + append-subexpansion(dest, key, index, subfails): { + k := 0 + while (k < subfails.size) { + dest.add(key + "[" + index + "]/" + subfails[k]) + k += 1 + } + } + + -- public -- assert-match(testcase, pattern): { fails := #find-unexpanded() fails.add-all(#find-mismatches(pattern)) Index: base.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/library/base.ws,v retrieving revision 1.58 retrieving revision 1.59 diff -u -d -r1.58 -r1.59 --- base.ws 30 Apr 2005 01:02:49 -0000 1.58 +++ base.ws 30 Apr 2005 04:42:34 -0000 1.59 @@ -413,7 +413,7 @@ size(): { return #entries.size !! 0; } - has(key): { + has-key(key): { i := (#entries.size !! 0) - 1; while (i >= 0) { if (#entries[i].key == key) { return true; } @@ -422,8 +422,8 @@ return false; } - key-at-index(i): { return #entries[i].key } - value-at-index(i): { return \#entries[i].value } + key-at(i): { return #entries[i].key } + value-at(i): { return \#entries[i].value } clear(): { #entries := ???; } } |
From: Jim K. <ki...@us...> - 2005-04-30 04:42:43
|
Update of /cvsroot/wheat/r1/root/applications In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19882/root/applications Modified Files: blog.ws farm.ws Log Message: Rename table.has to table.has-key (it isn't analogous in function to array.has). Also in table, rename key-at-index to key-at and value-at-index to value-at. In render, extract method append-subexpansion. In wheatunit, take a small step towards having a failure message be a renderable object rather than a string. Index: blog.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/applications/blog.ws,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- blog.ws 18 Mar 2005 07:18:50 -0000 1.30 +++ blog.ws 30 Apr 2005 04:42:33 -0000 1.31 @@ -62,7 +62,7 @@ name(request): { if (#user(\request)) { s := request.session("account"); - if (#users.has(s)) { return #users[s].name; } + if (#users.has-key(s)) { return #users[s].name; } } return "--nobody--"; } @@ -81,7 +81,7 @@ submit(request: r, post-args: args): { if (~ args.account.is-empty() ... && ~ args.password.is-empty() - ... && #blog.users.has(args.account) + ... && #blog.users.has-key(args.account) ... && #blog.users[args.account].password == args.password) { r.session("logged-in") := true; Index: farm.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/applications/farm.ws,v retrieving revision 1.64 retrieving revision 1.65 diff -u -d -r1.64 -r1.65 --- farm.ws 23 Apr 2005 00:50:54 -0000 1.64 +++ farm.ws 30 Apr 2005 04:42:34 -0000 1.65 @@ -384,7 +384,7 @@ tt-failed(): { return ~#subject.passed } tt-name(): { return #subject.name } tt-nonerror-message(): { - if (#subject.failure-error?) { + if (#subject.failure-info?) { #skip() } else { @@ -392,16 +392,19 @@ } } tt-reason-string(): { - if (#subject.failure-error?) { - #replace-text(#subject.failure-error.reason-string()) + `` TODO: lacking test coverage for this + if (#subject.failure-info?) { + #replace-text( + #subject.failure-info.error-value.reason-string()) } else { #skip() } } tt-trace-string(): { - if (#subject.failure-error?) { - trace := #subject.failure-error.trace-string() + `` TODO: lacking test coverage for this + if (#subject.failure-info?) { + trace := #subject.failure-info.error-value.trace-string() if (trace.is-empty()) { #skip() } |
From: Jim K. <ki...@us...> - 2005-04-30 01:02:57
|
Update of /cvsroot/wheat/r1/root/library In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6159/root/library Modified Files: base.ws render.ws wheatunit.ws Log Message: Add assert-match to render traces. Index: wheatunit.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/library/wheatunit.ws,v retrieving revision 1.43 retrieving revision 1.44 diff -u -d -r1.43 -r1.44 --- wheatunit.ws 30 Mar 2005 07:23:04 -0000 1.43 +++ wheatunit.ws 30 Apr 2005 01:02:49 -0000 1.44 @@ -120,8 +120,8 @@ } } - fail(): { - #assert("#fail called", false); + fail(message): { + #assert(message ?? "#fail called", false); } pass(): { Index: render.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/library/render.ws,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- render.ws 29 Apr 2005 21:09:53 -0000 1.37 +++ render.ws 30 Apr 2005 01:02:49 -0000 1.38 @@ -255,6 +255,105 @@ return t } + + -- private -- + + find-unexpanded(): { + baddies := [ ] + i := 0 + while (i < #map.size) { + action := #map.value-at-index(i).action + if (action.matches("unexpanded")) { + baddies.add(#map.key-at-index(i) + ": not expanded") + } + else if (action.matches("repeated")) { + key := #map.key-at-index(i) + repeats := \\#map.value-at-index(i).repeats + j := 0 + while (j < repeats.size) { + b := repeats[j].find-unexpanded() + k := 0 + while (k < b.size) { + baddies.add(key + "[" + j + "]/" + b[k]) + k += 1 + } + j += 1 + } + } + + i += 1 + } + return baddies; + } + + find-mismatches(pattern): { + pattern-stream := #array-stream.new(\\pattern) + baddies := [ ] + while (pattern-stream.more()) { + key := pattern-stream.next() + expected := pattern-stream.next() + action := #action(key) + + if (true == expected) { + if (~action.matches("kept")) { + baddies.add(key + ": wasn't kept, was " + action.value) + } + } + else if (false == expected) { + if (~action.matches("skipped")) { + baddies.add(key + ": wasn't skipped, was " + action.value) + } + } + else if (expected.is-string) { + if (~action.matches("replaced")) { + baddies.add(key + ": wasn't replaced, was " + action.value) + } + else { + actual := #replacement(key) + if (expected != actual) { + baddies.add(key + ": replace expected " + ... + expected + " was " + actual) + } + } + } + else { + if (~action.matches("repeated")) { + baddies.add(key + ": wasn't repeated, was " + action.value) + } + else { + count := #repeat-count(key) + if (expected.size != count) { + baddies.add(key + ": expected " + expected.size + ... + " repeats, was " + count) + } + j := 0 + while (j < count && j < expected.size) { + b := #repeat-index(key, j).find-mismatches(expected[j]) + k := 0 + while (k < b.size) { + baddies.add(key + "[" + j + "]/" + b[k]) + k += 1 + } + j += 1 + } + } + } + } + return baddies; + } + + assert-match(testcase, pattern): { + fails := #find-unexpanded() + fails.add-all(#find-mismatches(pattern)) + if (fails.size > 0) { + message := fails.join("\n") + if (fails.size > 1) { message += "\n" } + testcase.fail(message) + } + else { + testcase.pass() + } + } } request: { @@ -1032,4 +1131,126 @@ ..., trace.errors()) } + test-trace-match-all-expanded(): { + #check-trace-match("<body tt:name='do-replace-text' />", + \#trace-expander, + ???) + } + + test-trace-match-top-level-unexpanded(): { + #check-trace-match("<body tt:name='not-expanded' />", + \#trace-expander, + "not-expanded: not expanded") + } + + test-trace-match-unexpanded-inside-repeat(): { + #check-trace-match( +""( +<body tt:name='do-repeat'><p tt:name='bob'/></body> +""), + \#trace-expander, +""( +do-repeat[0]/bob: not expanded +do-repeat[1]/bob: not expanded +do-repeat[2]/bob: not expanded +do-repeat[3]/bob: not expanded +"") + ); + } + + test-trace-match(): { + #check-trace-match( + \#trace-template, + \#trace-expander, + pattern: [ + "do-keep", true, + "do-skip", false, + "do-replace-text", "123", + "do-repeat", [ + [ "count", "nil" ], + [ "count", "uno" ], + [ "count", "due" ], + [ "count", "tre" ] + ] + ], + "not-expanded: not expanded" + ) + } + + test-trace-match-notkept(): { + #check-trace-match( + "<p tt:name='do-replace-text'/>", + \#trace-expander, + pattern: [ "do-replace-text", true ], + "do-replace-text: wasn't kept, was replaced" + ) + } + + test-trace-match-notskipped(): { + #check-trace-match( + "<p tt:name='do-replace-text'/>", + \#trace-expander, + pattern: [ "do-replace-text", false ], + "do-replace-text: wasn't skipped, was replaced" + ) + } + + test-trace-match-notreplaced(): { + #check-trace-match( + "<p tt:name='do-keep'/>", + \#trace-expander, + pattern: [ "do-keep", "456" ], + "do-keep: wasn't replaced, was kept" + ) + } + + test-trace-match-badreplace(): { + #check-trace-match( + "<p tt:name='do-replace-text'/>", + \#trace-expander, + pattern: [ "do-replace-text", "456" ], + "do-replace-text: replace expected 456 was 123" + ) + } + + test-trace-match-notrepeated(): { + #check-trace-match( + "<p tt:name='do-replace-text'/>", + \#trace-expander, + pattern: [ "do-replace-text", [ ] ], + "do-replace-text: wasn't repeated, was replaced" + ) + } + + test-trace-match-repeat-count-wrong(): { + #check-trace-match( + "<p tt:name='do-repeat'><span tt:name='count'/></p>", + \#trace-expander, + pattern: [ "do-repeat", [ ["count", "zero"] ] ], +""( +do-repeat: expected 1 repeats, was 4 +do-repeat[0]/count: replace expected zero was nil +"") + ) + } + + + + check-trace-match(template, expander, message, pattern: pattern): { + trace := $/library/render.expand( + template: \\template, + expander: \\expander, + trace: true) + testcase := $/library/wheatunit/test-case.new() + trace.assert-match(\testcase, pattern) + result := $/library/wheatunit/result.new("local", testcase) + if (message?) { + #assert-equals(false, result.passed) + #assert-equals(message, result.failure-message) + } + else { + #assert-equals(true, result.passed) + } + } + } Index: base.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/library/base.ws,v retrieving revision 1.57 retrieving revision 1.58 diff -u -d -r1.57 -r1.58 --- base.ws 3 Apr 2005 07:48:00 -0000 1.57 +++ base.ws 30 Apr 2005 01:02:49 -0000 1.58 @@ -146,6 +146,13 @@ } return true; } + add-all(other): { + i := 0 + while (i < other.size) { + #add(other[i]) + i += 1 + } + } } nothingness: { @@ -414,6 +421,9 @@ } return false; } + + key-at-index(i): { return #entries[i].key } + value-at-index(i): { return \#entries[i].value } clear(): { #entries := ???; } } |
From: Jim K. <ki...@us...> - 2005-04-29 21:10:03
|
Update of /cvsroot/wheat/r1/wheat In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6258/wheat Modified Files: renderlibrary.cpp Log Message: Fix xmlencoding bug in renderlibrary. Traces now know about errors. A few renames and cleanups. Index: renderlibrary.cpp =================================================================== RCS file: /cvsroot/wheat/r1/wheat/renderlibrary.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- renderlibrary.cpp 8 Apr 2005 18:25:12 -0000 1.9 +++ renderlibrary.cpp 29 Apr 2005 21:09:53 -0000 1.10 @@ -262,11 +262,11 @@ default: ; } } - + rawTrace.send("add", False()); } - void + static void buildRawTrace(tt::Trace& trace, Local& rawTrace) { rawTrace = Array(); @@ -306,6 +306,7 @@ resultStream.open(); bool doTrace = traceArg.isBool() && traceArg.asBool(); + Local rawTrace(f); pt::string errors; @@ -325,16 +326,22 @@ else t.expand(ctx); } - if (doTrace) { - Local rawTrace(f); buildRawTrace(t.trace(), rawTrace); - return rawTrace; } } catch (const char* s) { errors += s; } catch (const pt::string& s) { errors += s; } + if (doTrace) { + if (!pt::isempty(errors)) { + rawTrace.send("add", String("errors")); // name + rawTrace.send("add", String("errors")); // actionStr + rawTrace.send("add", String(errors)); + } + return rawTrace; + } + sourceStream->close(); if (!pt::isempty(errors)) { @@ -345,7 +352,7 @@ "<hr />\n" "<pre>\n" ); - resultStream.put(errors); + resultStream.put(tt::xmlencode(errors)); resultStream.put("</pre>\n"); } |
From: Jim K. <ki...@us...> - 2005-04-29 21:10:02
|
Update of /cvsroot/wheat/r1/root/library In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6258/root/library Modified Files: render.ws Log Message: Fix xmlencoding bug in renderlibrary. Traces now know about errors. A few renames and cleanups. Index: render.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/library/render.ws,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- render.ws 23 Apr 2005 00:50:55 -0000 1.36 +++ render.ws 29 Apr 2005 21:09:53 -0000 1.37 @@ -4,13 +4,14 @@ Render Library ``) -expand(subject: s, expander: e, request: r, template: t, part: p, trace: tr): { +expand(subject: s, expander: e, request: r, template: template, + ... part: p, trace: trace): { c := #expander.context-for(subject: \\s, expander: \\e, request: \\r) - if (~t?) { - t := s.template(part: p, request: \\r) + if (~template?) { + template := s.template(part: p, request: \\r) } - r := #expand-prim(context: c, template: \\t, part: p, trace: tr) - if (tr) { return #expand-trace.from-raw(r) } + r := #expand-prim(context: c, template: \\template, part: p, trace: trace) + if (trace) { return #expand-trace.from-raw(r) } return r } @@ -174,11 +175,13 @@ expand-trace: { -- instance -- map: ??? + errors: "" -- public -- action-type: { :'/library/base/enum': values: ["unknown", "unexpanded", "kept", "skipped", "replaced", - "repeated", "ambiguous" + "repeated", "ambiguous", + "errors" ] } @@ -204,12 +207,20 @@ new(array): { return {:self: array: \\array; index: 0 } } next(): { v := #array[#index]; #index += 1; return v } more(): { return #index < #array.size } - done(): { return ~#done } } from-raw(raw-trace): { raw-stream := #array-stream.new(\\raw-trace) - return #build-from-raw(\raw-stream) + trace := #build-from-raw(\raw-stream) + if (raw-stream.more()) { + name := raw-stream.next() + action := raw-stream.next() + if (~ "errors" == action) { + return !!!("expected errors got " + action) + } + trace.errors := raw-stream.next() + } + return trace; } build-from-raw(raw-stream): { @@ -628,7 +639,7 @@ template := "<x tt:name='prefix' href='' />"; out := $/library/render.expand(template: template, expander: \e); #assert-contains(#errstr, out); - #assert-contains("bad prefix", out); + #assert-contains("<bad prefix>", out); template := "<x tt:name='replace' href='' />"; out := $/library/render.expand(template: template, expander: \e); @@ -636,15 +647,15 @@ #assert-contains( ""( While expanding tag replace (fetching value) -bad replace +<bad replace> ""), out); - #assert-contains("bad replace", out); + #assert-contains("<bad replace>", out); } error-attribute-expander: {:'/library/render/expander': - tt-prefix(): { #attribute("href", prefix: !!!("bad prefix")); } - tt-replace(): { #attribute("href", !!!("bad replace")); } + tt-prefix(): { #attribute("href", prefix: !!!("<bad prefix>")); } + tt-replace(): { #attribute("href", !!!("<bad replace>")); } } -- public -- @@ -1000,6 +1011,25 @@ } #assert-equals("unknown", trace.action("count").value) + + #assert-equals("", trace.errors()) + } + + test-error-with-trace(): { + renderlib := \$/library/render + trace := renderlib.expand( + template: "<body tt:name='prefix' href=''/>", + expander: \#error-attribute-expander, + trace: true) + #assert-equals(renderlib.absolute-path + "expand-trace", + trace.prototype().as-string) + + #assert-contains( +""( +While expanding tag prefix (fetching value) +<bad prefix> +"") + ..., trace.errors()) } } |
From: Kragen S. <kr...@us...> - 2005-04-23 00:51:03
|
Update of /cvsroot/wheat/r1/root/applications In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27215/root/applications Modified Files: farm.ws Log Message: Removed location dependencies and extraneous semicolons in farm.ws. Index: farm.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/applications/farm.ws,v retrieving revision 1.63 retrieving revision 1.64 diff -u -d -r1.63 -r1.64 --- farm.ws 3 Apr 2005 07:45:18 -0000 1.63 +++ farm.ws 23 Apr 2005 00:50:54 -0000 1.64 @@ -1,30 +1,30 @@ wheat(version: 1) -template: ->'/root/applications/farm.d/farm.html'; +template: ->'/root/applications/farm.d/farm.html' expander: {:'/applications/farm/farm-expander': tt-error: false } farm-expander: {:'/library/render/expander': tt-root-based-href(): - { #attribute("href", prefix: "/root/applications/farm.d/"); } [...1419 lines suppressed...] #assert-error("applications/farm/project-exists(farm)", - $/applications/farm.create-project("farm")); + ($..).create-project("farm")) `` can't create a project with name of existing package #assert-error("applications/farm/bad-project-name(prototype)", - $/applications/farm.create-project( - "prototype", \#sample-dev, \#sample-app)); + ($..).create-project("prototype", \#sample-dev, \#sample-app)) `` can't create a project with the name of common protocol - #sample-dev.remove-member("widget"); + #sample-dev.remove-member("widget") - #assert("project removed", ~proj-path.exists()); + #assert("project removed", ~proj-path.exists()) } -- instance -- |
From: Kragen S. <kr...@us...> - 2005-04-23 00:51:03
|
Update of /cvsroot/wheat/r1/root/library In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27215/root/library Modified Files: render.ws Log Message: Removed location dependencies and extraneous semicolons in farm.ws. Index: render.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/library/render.ws,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- render.ws 8 Apr 2005 18:25:12 -0000 1.35 +++ render.ws 23 Apr 2005 00:50:55 -0000 1.36 @@ -993,7 +993,7 @@ numbers := [ "nil", "uno", "due", "tre" ] i := 0 while (i < numbers.size) { - sub-trace := \trace.repeat-index("do-repeat", i); + sub-trace := \trace.repeat-index("do-repeat", i) #assert-equals("replaced", sub-trace.action("count").value) #assert-equals(numbers[i], sub-trace.replacement("count")) i += 1 |
From: Jim K. <ki...@us...> - 2005-04-20 00:29:04
|
Update of /cvsroot/wheat/r1/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14242/util Modified Files: test-test.cpp test.cpp test.h testutil.cpp Log Message: Let test-test.cpp have its own test group, rather than having to use the global one ("airplanes" no longer shows up in the regular test run). Index: test.h =================================================================== RCS file: /cvsroot/wheat/r1/util/test.h,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- test.h 28 Feb 2005 07:54:20 -0000 1.14 +++ test.h 20 Apr 2005 00:28:35 -0000 1.15 @@ -48,9 +48,22 @@ }; +class test; +typedef tstrlist<test> TestList; + +struct TestGroup { + string name; + TestList list; + + TestGroup(const char* n) : name(n) { } +}; + +typedef tstrlist<TestGroup> TestGroupList; + + class ptpublic test : public unknown { public: - test(const char* group, const char* name, + test(TestGroupList& list, const char* group, const char* name, const char* built = __DATE__ " " __TIME__); virtual void run() = 0; @@ -117,9 +130,11 @@ }; +extern TestGroupList& registry(); + #define TEST(group, name) \ struct Test_##group##_##name : public pt::test { \ - Test_##group##_##name() : pt::test(#group, #name) { } \ + Test_##group##_##name() : pt::test(pt::registry(), #group, #name) { } \ void run(); \ } test_##group##_##name; \ void Test_##group##_##name::run() @@ -155,28 +170,10 @@ CHECK((ptr) != 0) - - -/* The following is for communication between test.cpp and test-test.cpp. - We perhaps should move it when we think of a better way to do this. */ - -typedef tstrlist<test> TestList; - -struct TestGroup { - string name; - TestList list; - - TestGroup(const char* n) : name(n) { } -}; - -typedef tstrlist<TestGroup> TestGroupList; - extern bool pt::runAll( outstm& out, TestGroupList& tests, bool reportPerGroup, bool stopOnFailingGroup); -/* End test.cpp/test-test.cpp section */ - PTYPES_END #endif // INCLUDED_TEST_H Index: test-test.cpp =================================================================== RCS file: /cvsroot/wheat/r1/util/test-test.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- test-test.cpp 28 Feb 2005 07:54:20 -0000 1.11 +++ test-test.cpp 20 Apr 2005 00:28:35 -0000 1.12 @@ -257,9 +257,10 @@ } } +static TestGroupList tests(SL_SORTED | SL_DUPLICATES); struct Test_airplanes_takeoff : test { Test_airplanes_takeoff() - : test("airplanes", "takeoff", "Apr 6 2005 18:43:31") { } + : test(tests, "airplanes", "takeoff", "Apr 6 2005 18:43:31") { } void run(); } test_airplanes_takeoff; void Test_airplanes_takeoff::run() @@ -272,12 +273,6 @@ pt::outmemory out; out.open(); - TestGroupList tests(SL_SORTED | SL_DUPLICATES); - TestGroup group("airplanes"); - const string key("20050406184331airplanes"); - int gindex = tests.add(key, &group); - tests[gindex]->list.add("takeoff", &test_airplanes_takeoff); - pt::runAll(out, tests, false, false); pt::string output = out.get_strdata(); Index: testutil.cpp =================================================================== RCS file: /cvsroot/wheat/r1/util/testutil.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- testutil.cpp 21 Feb 2005 07:40:44 -0000 1.11 +++ testutil.cpp 20 Apr 2005 00:28:35 -0000 1.12 @@ -116,7 +116,7 @@ const Path& package, const pt::string& name, const pt::string& method) - : pt::test(name, method, 0), + : pt::test(pt::registry(), name, method, 0), mPackage(package), mMethod(method) { } Index: test.cpp =================================================================== RCS file: /cvsroot/wheat/r1/util/test.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- test.cpp 28 Feb 2005 07:54:20 -0000 1.17 +++ test.cpp 20 Apr 2005 00:28:35 -0000 1.18 @@ -128,19 +128,20 @@ -static TestGroupList& -registry() +TestGroupList& +pt::registry() { - // Because this global is used in other global initializers, - // in particular test::test(), we must us this trick - // to ensure that it is constructed before used. - // See C++ FAQ Lite, sections 10.11 through 10.13 + /* This trick is to ensure that this global is constructed before + it is used. + See C++ FAQ Lite, sections 10.11 through 10.13 + */ static TestGroupList* r = new TestGroupList(SL_SORTED | SL_DUPLICATES); return *r; } -test::test(const char* group, const char* name, const char* built) +test::test(TestGroupList& list, const char* group, const char* name, + const char* built) { string key; struct tm timeInfo; @@ -156,12 +157,12 @@ key += group; - int gindex = registry().indexof(key); + int gindex = list.indexof(key); if (gindex < 0) { - gindex = registry().add(key, new TestGroup(group)); + gindex = list.add(key, new TestGroup(group)); } - registry()[gindex]->list.add(name, this); + list[gindex]->list.add(name, this); } static bool anyPasses; |
From: Mark L. <mar...@us...> - 2005-04-15 17:38:52
|
Update of /cvsroot/wheat/r1/web-dev/source/cardfile In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv402/web-dev/source/cardfile Modified Files: cardfile.ws stack.html Log Message: displaying the table array card titles and body Index: cardfile.ws =================================================================== RCS file: /cvsroot/wheat/r1/web-dev/source/cardfile/cardfile.ws,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- cardfile.ws 2 Apr 2005 06:35:35 -0000 1.2 +++ cardfile.ws 15 Apr 2005 17:38:42 -0000 1.3 @@ -21,10 +21,24 @@ return \#stacks.last } stack-count(): { return #stacks.size() } + stack-by-title(title): { + i := 0 + while (i < #stacks.size()) { + if (#stacks[i].title == title) { + return \#stacks[i] + } + i += 1 + } + return ??? + } + render(request: r): { return $/library/render.redirect(\#stacks[0], request: \r); } expander: {:'/library/render/expander': + tt-title(): { + return #subject.title || "" + } tt-stack(): { #start-repeat() i := 0 @@ -85,6 +99,14 @@ containing-file(): { return \#container.container } + table-cols(): { return 3 } + table-rows(): { return (#table.size / #table-cols).ceiling + 1 } + table-card(row: i, col: j): { + k := i * #table-rows + j + if (#table[k]!) { return ??? } + else { return \#table[k] } + } + table-map(): { `` mostly for testing a := [ ] i := 0 @@ -123,7 +145,7 @@ $/library/render.url(\#subject, request:\#request)) } tt-title(): { - return #subject.title; + return #subject.title } tt-stacks(): { #expand(subject: \#subject.containing-file) @@ -131,41 +153,64 @@ tt-table-row(): { #start-repeat() - num-rows := #subject.table.size / 3 - i := 0 - while (i < num-rows) { - #expand(expand: {<:'/library/render/expander': - row: i - stack: \#subject - tt-table-card(): { - #start-repeat() - j := 0 - while (j < 3) { - k := #row * 3 + j; - if (#stack.table[k]?) { - #expand(subject: \#stack.table[k]) - } - else { - - } - j += 1 - } - } - }) - i += 1; + row := 0 + while (row < #subject.table-rows) { + #expand( + expander: \#row-expander, + subject: { row: row; stack: \#subject} + ) + row += 1; } } - tt-table-card(): { - + row-expander: {:'/library/render/expander': + tt-table-col(): { + #start-repeat() + col := 0 + while (col < #subject.stack.table-cols) { + #expand( + expander: \#col-expander, + subject: { + card: \\#subject.stack.table-card( + row: #subject.row, + col: col) + row: #subject.row + col: col + } + ) + col += 1 + } + } + + col-expander: {:'/library/render/expander': + tt-table-card(): { + if (#subject.card?) { #expand(subject: #subject.card) } + else { #skip() } + } + tt-add-href(): { + #attribute("href", + "add?row=" + #subject.row + ... + ";col=" + #subject.col + ) + } + } } } } card: { -- instance -- - title: ??? - body: ??? + title: "" + body: "" + -- public -- + expander: { :'/library/render/expander': + tt-title(): { + return #subject.title || "" + } + tt-body(): { + return #subject.body || "" + } + } } @@ -184,20 +229,25 @@ test-stack-basics(): { cf := $../cardfile.new() #assert-equals(2, cf.stack-count) - #assert-equals("stuff", cf.stacks[0].title) - #assert-equals("morgue", cf.stacks[1].title) - #assert-equals("change me", cf.stacks[0].table[0].title) - now := \cf.add-stack("now") + #assert-equals("morgue", cf.stack-by-title("morgue").title) + #assert-equals(???, cf.stack-by-title("not-present")) + + st-stuff := \cf.stack-by-title("stuff") + #assert-equals("stuff", st-stuff.title) + #assert-equals("change me", st-stuff.table.first.title) + + st-now := \cf.add-stack("now") #assert-equals(3, cf.stack-count) - #assert-equals("now", now.title) + #assert-equals("now", st-now.title) + #assert-equals("now", cf.stack-by-title("now").title) - later := \cf.add-stack("later") + st-later := \cf.add-stack("later") #assert-equals(4, cf.stack-count) - #assert-equals("later", later.title) + #assert-equals("later", st-later.title) #assert-equals(cf.absolute-path(), - now.containing-file.absolute-path()) + st-now.containing-file.absolute-path()) } test-card-basics(): { @@ -282,13 +332,13 @@ -- private -- setup(): { cf := $../cardfile.new() - cf.add-stack("now") - cf.add-stack("later") + st0 := \cf.add-stack("now") + st1 := \cf.add-stack("later") - st0 := \cf.stacks[0] st0.new-table-card(at: 0).title := "a" st0.new-table-card(at: 1).title := "b" st0.new-table-card(at: 2).title := "c" + st0.table[0].body := "hot stuff" l := [ "d", "e", "f", "g" ] i := 0 @@ -298,14 +348,38 @@ i += 1 } - st1 := \cf.stacks[1] st1.new-table-card(at: 1).title := "z" - st1.new-table-card(at: 4).title := "y" - st1.new-table-card(at: 6).title := "x" + st1.new-table-card(at: 3).title := "y" + st1.new-table-card(at: 5).title := "x" return cf; } + -- public -- + test-table-layout(): { + cf := #setup(); + + st := \cf.stack-by-title("morgue") + #assert-equals(1, st.table-rows) + #assert-equals(3, st.table-cols) + #assert-equals(???, st.table-card(row: 0, col: 0)) + + st := \cf.stack-by-title("later") + #assert-equals(3, st.table-rows) + #assert-equals(3, st.table-cols) + #assert-equals(???, st.table-card(row: 0, col: 0)) + #assert-equals("z", st.table-card(row: 0, col: 1).title) + #assert-equals(???, st.table-card(row: 0, col: 2)) + #assert-equals("y", st.table-card(row: 1, col: 0).title) + #assert-equals(???, st.table-card(row: 1, col: 1)) + #assert-equals("x", st.table-card(row: 1, col: 2).title) + #assert-equals(???, st.table-card(row: 2, col: 0)) + #assert-equals(???, st.table-card(row: 2, col: 1)) + #assert-equals(???, st.table-card(row: 2, col: 1)) + } + + -- private -- + sample-request(): { return $/library/render.tests.sample-request; } @@ -313,6 +387,10 @@ render(node): { return node.render(request: #sample-request); } + + expand-trace(node): { + return $/library/render.expand(subject: \\node, trace: true) + } -- public -- test-stack-render(): { @@ -330,6 +408,40 @@ #assert-contains("/stacks/3", html) } + test-stack-card-render(): { + cf := #setup() + st-now := \cf.stack-by-title("now") + + trace := #expand-trace(\st-now) + + #assert-equals("repeated", trace.action("table-row").value) + #assert-equals(3, trace.repeat-count("table-row")) + row-trace := trace.repeat-index("table-row", 0) + + #assert-equals("repeated", row-trace.action("table-col").value) + #assert-equals(3, row-trace.repeat-count("table-col")) + col-trace := row-trace.repeat-index("table-col", 0) + + #assert-equals("repeated", col-trace.action("table-card").value) + #assert-equals(1, col-trace.repeat-count("table-card")) + card-trace := col-trace.repeat-index("table-card", 0) + + #assert-equals("replaced", card-trace.action("title").value) + #assert-equals("a", card-trace.replacement("title")) + + #assert-equals("replaced", card-trace.action("body").value) + #assert-equals("hot stuff", card-trace.replacement("body")) + + col-trace := row-trace.repeat-index("table-col", 1) + card-trace := col-trace.repeat-index("table-card", 0) + + #assert-equals("replaced", card-trace.action("title").value) + #assert-equals("b", card-trace.replacement("title")) + + #assert-equals("replaced", card-trace.action("body").value) + #assert-equals("", card-trace.replacement("body")) + } + ``( things that are rendered @@ -340,10 +452,11 @@ stack tt-stacks (list of stacks) stack tt-title (trivial) stack tt-url (trivial) + stack tt-table-row (in proper order, proper number) + stack tt-table-col stack tt-table-card (proper card or place) stack tt-table-card-id - stack tt-table-card-url stack tt-table-card-delete-url stack tt-table-place-add-url stack tt-table-place-name @@ -359,6 +472,7 @@ card tt-title (trivial) card tt-body (writeup formatted, trivial) card tt-body-raw (trivial) + card tt-utl (trivial) ``) ``( operations when viewing a stack or a card come back as GETs and POSTs: Index: stack.html =================================================================== RCS file: /cvsroot/wheat/r1/web-dev/source/cardfile/stack.html,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- stack.html 2 Apr 2005 06:35:35 -0000 1.2 +++ stack.html 15 Apr 2005 17:38:42 -0000 1.3 @@ -17,13 +17,15 @@ <div id="content"> <table id="table"> <tr tt:name="table-row"> - <td td:name="table-card"><div class="place" id="placeA"> - <p>ⓐ</p> + <td tt:name="table-col"><div class="place" id="placeA"> + <p tt:name="place-label">ⓐ</p> <ul class="placeControls"> - <li><a href="?op=add;item=placeA" title="add new card">+</a></li> + <li><a tt:name="add-href" href="add?table=0" title="add new card"> + +</a></li> </ul> - <div class="card" id="cardA"> - <h2 title="drag to rearrange">Sew Sails</h2> + <div tt:name="table-card" class="card" id="cardA"> + <h2 title="drag to rearrange" tt:name="title">Sew Sails</h2> + <tt:span name="body"> <p>The sails should be rectangles that are approx. 30' by 8'. </p> <p>Traditionally they are made out of canvas, but in this @@ -31,13 +33,14 @@ hemp blend.</p> <p>We'd like them to be a sort of Robin's egg blue, though with a tinge of red. And maybe a cool white stripe.</p> + </tt:span> <ul class="cardControls"> <li><a href="cardA" title="view and edit card">✎</a></li> <li><a href="?op=delete;item=cardA" title="delete card">×</a></li> </ul> </div> </div></td> - <td><div class="place" id="placeB"> + <td tt:example="table-col"><div class="place" id="placeB"> <p>ⓑ</p> <ul class="placeControls"> <li><a href="?op=add;item=placeB" title="add new card">+</a></li> @@ -52,15 +55,16 @@ </div> </div> </td> - <td><div class="place" id="placeC"> + <td tt:example="table-col"><div class="place" id="placeC"> <p>ⓒ</p> <ul class="placeControls"> - <li><a href="?op=add;item=placeC" title="add new card">+</a></li> + <li><a href="?op=add;item=placeC" title="add new card"> <span style="display:none;"><tt:attribute for="href">add?table=<tt:span name="place-index">0</tt:span></tt:attribute></span> ++</a></li> </ul> </div> </td> </tr> - <tr> + <tr tt:example="table-row"> <td><div class="place" id="placeD"> <p>ⓓ</p> <ul class="placeControls"> @@ -97,7 +101,7 @@ </div> </div></td> </tr> - <tr> + <tr tt:example="table-row"> <td><div class="place" id="placeG"> <p>ⓖ</p> <ul class="placeControls"> |
From: Kragen S. <kr...@us...> - 2005-04-09 03:22:48
|
Update of /cvsroot/wheat/r1/web-dev/source/graffiti In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5850/web-dev/source/graffiti Added Files: graffiti.ws Log Message: Donovan and I are checking in some prototype LivePage functionality for Wheat. --- NEW FILE: graffiti.ws --- wheat(version: 1) `` graffiti wall graffiti-wall: { -- instance -- wall-name: "Brick Wall" wall-graffiti: ??? -- public -- add(new-graffito): { #wall-graffiti.push(new-graffito) } initialize(): { #wall-graffiti := [ "Kilroy was here", "For a good time call 867-5309"] } submit(post-args:p, request:r): { ``p.low-level-debug #add(p.new-graffito) return $/library/render.redirect(\self, request:r) } template: ""( <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>Wall</title> <script type="text/javascript"> //<![CDATA[ var createRequest = function() { return new XMLHttpRequest() } UNINITIALIZED = 0 LOADING = 1 LOADED = 2 INTERACTIVE = 3 COMPLETED = 4 var invokeAction = function(whatAction, whatId, arguments) { var request = createRequest() request.onreadystatechange = function() { if (request.readyState == COMPLETED) { document.open() document.write(request.responseText) document.close() /* try { var oldNode = document.getElementById(whatId) oldNode.id = '' var newNodeInNewDocument = request.responseXML.getElementById(whatId) alert(newNodeInNewDocument) var newNode = document.importNode(newNodeInNewDocument, true) oldNode.parentNode.replaceChild(newNode, oldNode) alert(request.responseText) } catch (e) { window.fuckedup = e } */ } } request.open('POST', 'http://localhost:8100/garden/thingy') request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded') var encoded = [] for (var key in arguments) { encoded.push( encodeURIComponent(key) + '=' + encodeURIComponent(arguments[key])) } request.overrideMimeType('text/xml') request.send(encoded.join('&')) } //]]> </script> </head> <body> <h1 tt:name="wall-name">Wall</h1> <ul id="theWall"> <li tt:name="wall-graffiti"><tt:span tt:name="graffito">Graffito</tt:span></li> </ul> <form method="POST" onsubmit="invokeAction('hello', 'theWall', {'new-graffito': this['new-graffito'].value}); return false"> <input name="new-graffito" /> <input name="op" value="add" type="submit" /> </form> </body> </html> "") expander: {:'/library/render/expander': tt-wall-name():{ return #subject.wall-name } tt-wall-graffiti(): { #start-repeat() i := 0 g := #subject.wall-graffiti while (i < g.size) { #expand(subject: g[i], expander: \#graffito-expander) i += 1 } } graffito-expander: {:'/library/render/expander': tt-graffito(): { return #subject } } } } ``( We got this error when we were missing a close curly brace: 500 Wheat error library/buffer/exception/invalid-line-number(40) unknown source:?: generated by mark-line-end() /root/applications/farm.ws:262: returned to process-error() /root/applications/farm.ws:246: returned to do-compile() /root/applications/farm.ws:213: returned to submit() Wheat/r1 at resilient:8100 ``) ``( We used the instantiator and gave it a url which already existed; it properly blew away the old object and gave us a new one, but gave us no warning that it was going to do so. ``) instantiables: [ -> '/applications/graffiti/graffiti-wall' ] sample-graffiti-wall: {:'/applications/graffiti/graffiti-wall':} tests: {:'/library/wheatunit/test-case': create-wall(): { s := \$../sample-graffiti-wall s.initialize() return \s } test-title(): { html := #create-wall.render() #assert-contains("<h1>Brick Wall</h1>", html) } test-graffiti(): { html := #create-wall.render() #assert-contains("<li>Kilroy was here</li>", html) } test-adding(): { wall := #create-wall wall.add("More graffiti") html := wall.render() #assert-contains("<li>More graffiti</li>", html) } test-adding-web(): { wall := \#create-wall what := wall.submit( post-args:{ op: "add" new-graffito: "Hello" }, request:#sample-request) #assert-equals("see-other", what.type) #assert-equals($/library/render.url(\wall, request:#sample-request), what.location) html := wall.render() #assert-contains("<li>Hello</li>", html) } sample-request(): { return $/library/render.tests.sample-request; } } |