Mercurial Hosting > luan
diff scripts/test.luan @ 497:55f9f74f1e55
Http.request is now pure luan
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 17 May 2015 19:25:47 -0600 |
parents | 598123096772 |
children | 92c3d22745b8 |
line wrap: on
line diff
--- a/scripts/test.luan Sat May 16 20:19:05 2015 -0600 +++ b/scripts/test.luan Sun May 17 19:25:47 2015 -0600 @@ -1,8 +1,9 @@ local Luan = require "luan:Luan" -local assert = Luan.assert +local error = Luan.error local range = Luan.range local Io = require "luan:Io" local Http = require "luan:http/Http" +local init_for_test = Http.init_for_test local Lucene = require "luan:lucene/Lucene" local Ab_testing = require "luan:lucene/Ab_testing" @@ -16,15 +17,15 @@ end -Http.init_for_test() -Http.request.parameters.code = "require('luan:Io').print 'hi'" +init_for_test() +Http.request.parameter.code = "require('luan:Io').print 'hi'" page = Http.get_page "/run" -assert( page.trim() == "hi" ) +page.trim() == "hi" or error "failed" -Http.init_for_test() -Http.request.parameters.cmd = "'ab'..'cd'" +init_for_test() +Http.request.parameter.cmd = "'ab'..'cd'" page = Http.get_page "/shell" -assert( page.find "abcd" ) +page.find "abcd" or error "failed" -- lucene @@ -50,8 +51,48 @@ db.save_document(doc) end -Http.init_for_test() +init_for_test() ab_testing.web_page{"All","null"}.respond() +local Web_search = require "luan:lucene/Web_search" +local web_search = Web_search.of(db) + +init_for_test() +web_search.respond() + +init_for_test() +Http.request.parameter.query = "Query.all_docs" +Http.request.parameter.rows = "100" +Http.request.parameter.sort = "" +web_search.respond() + + +-- website + +function Io.schemes.site(path,add_extension) + return Io.uri( "file:../website/src"..path, add_extension ) +end + +init_for_test(); Http.get_page "/" +init_for_test(); Http.get_page "/docs.html" +init_for_test(); Http.get_page "/tutorial.html" +init_for_test(); Http.get_page "/pil.html" +init_for_test(); Http.get_page "/manual.html" +init_for_test(); Http.get_page "/diff.html" +init_for_test(); Http.get_page "/examples/hi" +init_for_test(); Http.get_page "/examples/hi2" +init_for_test(); Http.get_page "/examples/hi2_simply_html" +init_for_test(); Http.get_page "/examples/shell" + +init_for_test() +Http.request.parameter.name = "bob" +page = Http.get_page "/examples/hi2" +page.find "bob" or error "failed" + +init_for_test() +Http.request.parameter.name = "bob" +page = Http.get_page "/examples/hi2_simply_html" +page.find "bob" or error "failed" + print "done"