mirror of
https://github.com/Noratrieb/riverdelta.git
synced 2026-01-14 16:35:03 +01:00
fix tests
This commit is contained in:
parent
e455e71aa2
commit
309a286a1a
2 changed files with 41 additions and 11 deletions
|
|
@ -4,44 +4,62 @@ exports[`should tokenize an emtpy function 1`] = `
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"kind": "function",
|
"kind": "function",
|
||||||
"span": {
|
"span": Span {
|
||||||
"end": 8,
|
"end": 8,
|
||||||
|
"file": {
|
||||||
|
"content": "function hello() = ;",
|
||||||
|
},
|
||||||
"start": 0,
|
"start": 0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ident": "hello",
|
"ident": "hello",
|
||||||
"kind": "identifier",
|
"kind": "identifier",
|
||||||
"span": {
|
"span": Span {
|
||||||
"end": 14,
|
"end": 14,
|
||||||
|
"file": {
|
||||||
|
"content": "function hello() = ;",
|
||||||
|
},
|
||||||
"start": 9,
|
"start": 9,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"kind": "(",
|
"kind": "(",
|
||||||
"span": {
|
"span": Span {
|
||||||
"end": 15,
|
"end": 15,
|
||||||
|
"file": {
|
||||||
|
"content": "function hello() = ;",
|
||||||
|
},
|
||||||
"start": 14,
|
"start": 14,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"kind": ")",
|
"kind": ")",
|
||||||
"span": {
|
"span": Span {
|
||||||
"end": 16,
|
"end": 16,
|
||||||
|
"file": {
|
||||||
|
"content": "function hello() = ;",
|
||||||
|
},
|
||||||
"start": 15,
|
"start": 15,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"kind": "=",
|
"kind": "=",
|
||||||
"span": {
|
"span": Span {
|
||||||
"end": 18,
|
"end": 18,
|
||||||
|
"file": {
|
||||||
|
"content": "function hello() = ;",
|
||||||
|
},
|
||||||
"start": 17,
|
"start": 17,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"kind": ";",
|
"kind": ";",
|
||||||
"span": {
|
"span": Span {
|
||||||
"end": 20,
|
"end": 20,
|
||||||
|
"file": {
|
||||||
|
"content": "function hello() = ;",
|
||||||
|
},
|
||||||
"start": 19,
|
"start": 19,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -53,30 +71,42 @@ exports[`should tokenize hello world 1`] = `
|
||||||
{
|
{
|
||||||
"ident": "print",
|
"ident": "print",
|
||||||
"kind": "identifier",
|
"kind": "identifier",
|
||||||
"span": {
|
"span": Span {
|
||||||
"end": 5,
|
"end": 5,
|
||||||
|
"file": {
|
||||||
|
"content": "print("hello world")",
|
||||||
|
},
|
||||||
"start": 0,
|
"start": 0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"kind": "(",
|
"kind": "(",
|
||||||
"span": {
|
"span": Span {
|
||||||
"end": 6,
|
"end": 6,
|
||||||
|
"file": {
|
||||||
|
"content": "print("hello world")",
|
||||||
|
},
|
||||||
"start": 5,
|
"start": 5,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"kind": "lit_string",
|
"kind": "lit_string",
|
||||||
"span": {
|
"span": Span {
|
||||||
"end": 19,
|
"end": 19,
|
||||||
|
"file": {
|
||||||
|
"content": "print("hello world")",
|
||||||
|
},
|
||||||
"start": 6,
|
"start": 6,
|
||||||
},
|
},
|
||||||
"value": "hello world",
|
"value": "hello world",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"kind": ")",
|
"kind": ")",
|
||||||
"span": {
|
"span": Span {
|
||||||
"end": 20,
|
"end": 20,
|
||||||
|
"file": {
|
||||||
|
"content": "print("hello world")",
|
||||||
|
},
|
||||||
"start": 19,
|
"start": 19,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import { lines } from "./error";
|
||||||
it("should extract lines correctly", () => {
|
it("should extract lines correctly", () => {
|
||||||
const input = "AAA\nmeow\n:3\n\n";
|
const input = "AAA\nmeow\n:3\n\n";
|
||||||
|
|
||||||
const lineSpans = lines(input);
|
const lineSpans = lines({ content: input });
|
||||||
const lineContents = lineSpans.map(({ start, end }) =>
|
const lineContents = lineSpans.map(({ start, end }) =>
|
||||||
input.slice(start, end)
|
input.slice(start, end)
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue