tests: build vweb example
parent
8277c976a8
commit
931cf86cc3
|
@ -231,7 +231,14 @@ pub fn v_build_failing_skipped(zargs string, folder string, skipped []string) bo
|
||||||
mut mains := []string{}
|
mut mains := []string{}
|
||||||
for f in files {
|
for f in files {
|
||||||
if !f.contains('modules') && !f.contains('preludes') {
|
if !f.contains('modules') && !f.contains('preludes') {
|
||||||
if f.contains('life_gg') || f.contains('/graph.v') || f.contains('/vweb/') || f.contains('/pg/') || f.contains('rune.v') {
|
//$if !linux {
|
||||||
|
// run pg example only on linux
|
||||||
|
if f.contains('/pg/') {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
//}
|
||||||
|
|
||||||
|
if f.contains('life_gg') || f.contains('/graph.v') || f.contains('rune.v') {
|
||||||
continue
|
continue
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,55 +1,58 @@
|
||||||
//import pg
|
import pg
|
||||||
|
|
||||||
struct Modules {
|
struct Modules {
|
||||||
id int
|
id int
|
||||||
user_id int
|
user_id int
|
||||||
name string
|
name string
|
||||||
url string
|
url string
|
||||||
//nr_downloads int
|
//nr_downloads int
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_orm() {
|
fn test_orm() {
|
||||||
/*
|
db := pg.connect(
|
||||||
db := pg.connect('vpm', 'alex')
|
dbname:'vpm'
|
||||||
//nr_modules := db.select count from modules
|
user:'alex'
|
||||||
//nr_modules := db.select count from Modules where id == 1
|
)
|
||||||
nr_modules := db.select count from Modules where
|
/*
|
||||||
name == 'Bob' && id == 1
|
//nr_modules := db.select count from modules
|
||||||
println(nr_modules)
|
//nr_modules := db.select count from Modules where id == 1
|
||||||
|
nr_modules := db.select count from Modules where
|
||||||
mod := db.select from Modules where id = 1 limit 1
|
name == 'Bob' && id == 1
|
||||||
println(mod)
|
println(nr_modules)
|
||||||
|
|
||||||
mods := db.select from Modules limit 10
|
mod := db.select from Modules where id = 1 limit 1
|
||||||
for mod in mods {
|
println(mod)
|
||||||
println(mod)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
mods := db.select from Modules limit 10
|
||||||
mod := db.retrieve<Module>(1)
|
for mod in mods {
|
||||||
|
println(mod)
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
mod := db.update Module set name = name + '!' where id > 10
|
/*
|
||||||
|
mod := db.retrieve<Module>(1)
|
||||||
|
|
||||||
|
mod := db.update Module set name = name + '!' where id > 10
|
||||||
|
|
||||||
|
|
||||||
nr_modules := db.select count from Modules
|
nr_modules := db.select count from Modules
|
||||||
where id > 1 && name == ''
|
where id > 1 && name == ''
|
||||||
println(nr_modules)
|
println(nr_modules)
|
||||||
|
|
||||||
nr_modules := db.select count from modules
|
nr_modules := db.select count from modules
|
||||||
nr_modules := db.select from modules
|
nr_modules := db.select from modules
|
||||||
nr_modules := db[:modules].select
|
nr_modules := db[:modules].select
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
mod := select from db.modules where id = 1 limit 1
|
mod := select from db.modules where id = 1 limit 1
|
||||||
println(mod.name)
|
println(mod.name)
|
||||||
top_mods := select from db.modules where nr_downloads > 1000 order by nr_downloads desc limit 10
|
top_mods := select from db.modules where nr_downloads > 1000 order by nr_downloads desc limit 10
|
||||||
top_mods := db.select from modules where nr_downloads > 1000 order by nr_downloads desc limit 10
|
top_mods := db.select from modules where nr_downloads > 1000 order by nr_downloads desc limit 10
|
||||||
top_mods := db.select<Module>(m => m.nr_downloads > 1000).order_by(m => m.nr_downloads).desc().limit(10)
|
top_mods := db.select<Module>(m => m.nr_downloads > 1000).order_by(m => m.nr_downloads).desc().limit(10)
|
||||||
names := select name from db.modules // []string
|
names := select name from db.modules // []string
|
||||||
|
|
||||||
|
|
||||||
n := db.q_int('select count(*) from modules')
|
n := db.q_int('select count(*) from modules')
|
||||||
println(n)
|
println(n)
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,8 +87,19 @@ fn (mut p Parser) vweb() ast.ComptimeCall {
|
||||||
// Compile vweb html template to V code, parse that V code and embed the resulting V function
|
// Compile vweb html template to V code, parse that V code and embed the resulting V function
|
||||||
// that returns an html string.
|
// that returns an html string.
|
||||||
mut path := p.cur_fn_name + '.html'
|
mut path := p.cur_fn_name + '.html'
|
||||||
// if p.pref.is_debug {
|
// if p.pref.is_verbose {
|
||||||
println('>>> compiling vweb HTML template "$path"')
|
println('>>> compiling vweb HTML template "$path"')
|
||||||
|
// }
|
||||||
|
if !os.exists(path) {
|
||||||
|
// Can't find the template file in current directory,
|
||||||
|
// try looking next to the vweb program, in case it's run with
|
||||||
|
// v path/to/vweb_app.v
|
||||||
|
path = os.dir(p.scanner.file_path) + '/' + path
|
||||||
|
if !os.exists(path) {
|
||||||
|
p.error('vweb HTML template "$path" not found')
|
||||||
|
}
|
||||||
|
// println('path is now "$path"')
|
||||||
|
}
|
||||||
v_code := tmpl.compile_file(path)
|
v_code := tmpl.compile_file(path)
|
||||||
mut scope := &ast.Scope{
|
mut scope := &ast.Scope{
|
||||||
start_pos: 0
|
start_pos: 0
|
||||||
|
@ -102,17 +113,6 @@ fn (mut p Parser) vweb() ast.ComptimeCall {
|
||||||
println('>>> end of vweb template END')
|
println('>>> end of vweb template END')
|
||||||
println('\n\n')
|
println('\n\n')
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
if !os.exists(path) {
|
|
||||||
// Can't find the template file in current directory,
|
|
||||||
// try looking next to the vweb program, in case it's run with
|
|
||||||
// v path/to/vweb_app.v
|
|
||||||
path = os.dir(p.scanner.file_path) + '/' + path
|
|
||||||
if !os.exists(path) {
|
|
||||||
p.error('vweb HTML template "$path" not found')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
// copy vars from current fn scope into vweb_tmpl scope
|
// copy vars from current fn scope into vweb_tmpl scope
|
||||||
for stmt in file.stmts {
|
for stmt in file.stmts {
|
||||||
if stmt is ast.FnDecl {
|
if stmt is ast.FnDecl {
|
||||||
|
|
Loading…
Reference in New Issue