Add examples and move tests to the tests/ folder
This commit is contained in:
@@ -9,8 +9,8 @@ all: wl
|
||||
wl: wl.c wl.h main.c
|
||||
gcc main.c wl.c -o wl -g3 -O0
|
||||
|
||||
test: wl.c wl.h test.c
|
||||
gcc test.c wl.c -o test -g3 -O0
|
||||
test: wl.c wl.h tests/test.c
|
||||
gcc tests/test.c wl.c -o test -g3 -O0
|
||||
|
||||
coverage:
|
||||
gcc main.c wl.c -o wl_cov -g3 -O0 --coverage -fprofile-arcs -ftest-coverage
|
||||
@@ -22,8 +22,8 @@ coverage_report:
|
||||
lcov --remove coverage.info '/usr/*' --output-file coverage_filtered.info
|
||||
genhtml coverage_filtered.info --output-directory coverage_html --title "WL Template Engine Coverage"
|
||||
|
||||
fuzz: fuzz.c wl.c wl.h
|
||||
$(AFL_CC) fuzz.c wl.c -o fuzz \
|
||||
fuzz: tests/fuzz.c wl.c wl.h
|
||||
$(AFL_CC) tests/fuzz.c wl.c -o fuzz \
|
||||
-g -O3 -Wall \
|
||||
-fsanitize=address,undefined \
|
||||
-fno-omit-frame-pointer
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
* Don't allow [] selections to go over newlines
|
||||
* Make sure maps and arrays can be keys of a map
|
||||
* Make sure maps and arrays can't be keys of a map
|
||||
* Decide and document how comments work
|
||||
* Improve the formatting of the output
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
let items = ['Apple', 'Orange', 'Strawberry']
|
||||
|
||||
let list =
|
||||
<ul>
|
||||
\for item in items:
|
||||
<li>\{escape item}</li>
|
||||
</ul>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Fruit List</title>
|
||||
</head>
|
||||
<body>
|
||||
My list:
|
||||
\{list}
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,13 @@
|
||||
|
||||
procedure my_page_template(title, content) {
|
||||
<html>
|
||||
<head>
|
||||
<title>\{escape title}</title>
|
||||
</head>
|
||||
<body>
|
||||
\{content}
|
||||
</body>
|
||||
</html>
|
||||
}
|
||||
|
||||
my_page_template("Welcome to my webpage!", <article>Content of my page</article>)
|
||||
@@ -0,0 +1,73 @@
|
||||
|
||||
let comments = [
|
||||
{
|
||||
'content': 'Cool post!',
|
||||
'children': [
|
||||
{
|
||||
'content': 'True!',
|
||||
'children': []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
'content': 'I don\'t agree with the second section..',
|
||||
'children': [
|
||||
{
|
||||
'content': 'You\'re wrong!',
|
||||
'children': [
|
||||
{
|
||||
'content': 'No, YOU are wrong!',
|
||||
'children' : []
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
]
|
||||
|
||||
procedure render_comment_subtree(comment) {
|
||||
<div class="comment">
|
||||
<p>\{escape comment.content}</p>
|
||||
<div class="comment-children">
|
||||
\for child in comment.children:
|
||||
render_comment_subtree(child)
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<style>
|
||||
.comment {
|
||||
border-left: 2px solid #ccc;
|
||||
padding-left: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<article>
|
||||
|
||||
<h1>A Very Cool Post</h1>
|
||||
|
||||
<h2>Section 1</h2>
|
||||
|
||||
<p>
|
||||
This language is cool
|
||||
</p>
|
||||
|
||||
<h2>Section 2</h2>
|
||||
|
||||
<p>
|
||||
You should try it out
|
||||
</p>
|
||||
|
||||
</article>
|
||||
|
||||
<div id="comments">
|
||||
\for comment in comments:
|
||||
render_comment_subtree(comment)
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,7 +0,0 @@
|
||||
|
||||
procedure page(title, lang)
|
||||
<html lang="\{lang}">
|
||||
\{title}
|
||||
</html>
|
||||
|
||||
page("Hello, world!", "it")
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "wl.h"
|
||||
#include "../wl.h"
|
||||
|
||||
#define MAX_INPUT_SIZE (64 * 1024) // 64KB max input
|
||||
#define ARENA_SIZE (1 << 20) // 1MB arena
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user