Mercurial Hosting > luan
diff scripts/test.luan @ 503:92c3d22745b8
make _ENV optional
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 20 May 2015 23:24:46 -0600 |
parents | 55f9f74f1e55 |
children | 7bc63886d4f2 |
line wrap: on
line diff
--- a/scripts/test.luan Tue May 19 17:57:20 2015 -0600 +++ b/scripts/test.luan Wed May 20 23:24:46 2015 -0600 @@ -1,10 +1,26 @@ +local Binary = require "luan:Binary" +local Debug = require "luan:Debug" +local Html = require "luan:Html" +local Io = require "luan:Io" local Luan = require "luan:Luan" +local Math = require "luan:Math" +local Package = require "luan:Package" +local String = require "luan:String" +local Table = require "luan:Table" +local Thread = require "luan:Thread" +local Time = require "luan:Time" +local Hosting = require "luan:host/Hosting" +local Http = require "luan:http/Http" +local HttpTest = require "luan:http/HttpTest" +local Server = require "luan:http/Server" +local Lucene = require "luan:lucene/Lucene" +local Mail = require "luan:mail/Mail" +local Stripe = require "luan:stripe/Stripe" + 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 init = HttpTest.init +local get_page = HttpTest.get_page local Ab_testing = require "luan:lucene/Ab_testing" @@ -16,30 +32,31 @@ return Io.uri( "luan:http"..path, add_extension ) end +local page -init_for_test() +init() Http.request.parameter.code = "require('luan:Io').print 'hi'" -page = Http.get_page "/run" +page = get_page "/run" page.trim() == "hi" or error "failed" -init_for_test() +init() Http.request.parameter.cmd = "'ab'..'cd'" -page = Http.get_page "/shell" +page = get_page "/shell" page.find "abcd" or error "failed" -- lucene -this_file = Io.schemes.file(Luan.arg[0]) -this_dir = this_file.parent() -lucene_dir = this_dir.parent().child("build").child("lucene_test") +local this_file = Io.schemes.file(Luan.arg[0]) +local this_dir = this_file.parent() +local lucene_dir = this_dir.parent().child("build").child("lucene_test") --print(lucene_dir.to_string()) -db = Lucene.index(lucene_dir.to_string()) +local db = Lucene.index(lucene_dir.to_string()) db.delete_all() -ab_testing = Ab_testing.of(db) -test_events = {"all"} -aggregator_factories = { +local ab_testing = Ab_testing.of(db) +local test_events = {"all"} +local aggregator_factories = { all = Ab_testing.count_all; } ab_testing.test{ name="All", values={"all"}, events=test_events, aggregator_factories=aggregator_factories } @@ -51,16 +68,16 @@ db.save_document(doc) end -init_for_test() +init() 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() +init() web_search.respond() -init_for_test() +init() Http.request.parameter.query = "Query.all_docs" Http.request.parameter.rows = "100" Http.request.parameter.sort = "" @@ -73,25 +90,25 @@ 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(); get_page "/" +init(); get_page "/docs.html" +init(); get_page "/tutorial.html" +init(); get_page "/pil.html" +init(); get_page "/manual.html" +init(); get_page "/diff.html" +init(); get_page "/examples/hi" +init(); get_page "/examples/hi2" +init(); get_page "/examples/hi2_simply_html" +init(); get_page "/examples/shell" -init_for_test() +init() Http.request.parameter.name = "bob" -page = Http.get_page "/examples/hi2" +page = get_page "/examples/hi2" page.find "bob" or error "failed" -init_for_test() +init() Http.request.parameter.name = "bob" -page = Http.get_page "/examples/hi2_simply_html" +page = get_page "/examples/hi2_simply_html" page.find "bob" or error "failed"