fixes to get tests green with karma dart

This commit is contained in:
Chirayu Krishnappa 2014-10-01 19:58:22 -07:00
parent d7d52aaef2
commit 78d758b4bb
3 changed files with 58 additions and 56 deletions

View File

@ -109,59 +109,58 @@ function newNumberToken(index:int, n:number):Token {
var EOF:Token = new Token(-1, 0, 0, ""); var EOF:Token = new Token(-1, 0, 0, "");
// TODO(chirayu): Rewrite as consts when possible. const $EOF = 0;
var $EOF = 0; const $TAB = 9;
var $TAB = 9; const $LF = 10;
var $LF = 10; const $VTAB = 11;
var $VTAB = 11; const $FF = 12;
var $FF = 12; const $CR = 13;
var $CR = 13; const $SPACE = 32;
var $SPACE = 32; const $BANG = 33;
var $BANG = 33; const $DQ = 34;
var $DQ = 34; const $$ = 36;
var $$ = 36; const $PERCENT = 37;
var $PERCENT = 37; const $AMPERSAND = 38;
var $AMPERSAND = 38; const $SQ = 39;
var $SQ = 39; const $LPAREN = 40;
var $LPAREN = 40; const $RPAREN = 41;
var $RPAREN = 41; const $STAR = 42;
var $STAR = 42; const $PLUS = 43;
var $PLUS = 43; const $COMMA = 44;
var $COMMA = 44; const $MINUS = 45;
var $MINUS = 45; const $PERIOD = 46;
var $PERIOD = 46; const $SLASH = 47;
var $SLASH = 47; const $COLON = 58;
var $COLON = 58; const $SEMICOLON = 59;
var $SEMICOLON = 59; const $LT = 60;
var $LT = 60; const $EQ = 61;
var $EQ = 61; const $GT = 62;
var $GT = 62; const $QUESTION = 63;
var $QUESTION = 63;
var $0 = 48; const $0 = 48;
var $9 = 57; const $9 = 57;
var $A = 65, $B = 66, $C = 67, $D = 68, $E = 69, $F = 70, $G = 71, $H = 72, const $A = 65, $B = 66, $C = 67, $D = 68, $E = 69, $F = 70, $G = 71, $H = 72,
$I = 73, $J = 74, $K = 75, $L = 76, $M = 77, $N = 78, $O = 79, $P = 80, $I = 73, $J = 74, $K = 75, $L = 76, $M = 77, $N = 78, $O = 79, $P = 80,
$Q = 81, $R = 82, $S = 83, $T = 84, $U = 85, $V = 86, $W = 87, $X = 88, $Q = 81, $R = 82, $S = 83, $T = 84, $U = 85, $V = 86, $W = 87, $X = 88,
$Y = 89, $Z = 90; $Y = 89, $Z = 90;
var $LBRACKET = 91; const $LBRACKET = 91;
var $BACKSLASH = 92; const $BACKSLASH = 92;
var $RBRACKET = 93; const $RBRACKET = 93;
var $CARET = 94; const $CARET = 94;
var $_ = 95; const $_ = 95;
var $a = 97, $b = 98, $c = 99, $d = 100, $e = 101, $f = 102, $g = 103, const $a = 97, $b = 98, $c = 99, $d = 100, $e = 101, $f = 102, $g = 103,
$h = 104, $i = 105, $j = 106, $k = 107, $l = 108, $m = 109, $n = 110, $h = 104, $i = 105, $j = 106, $k = 107, $l = 108, $m = 109, $n = 110,
$o = 111, $p = 112, $q = 113, $r = 114, $s = 115, $t = 116, $u = 117, $o = 111, $p = 112, $q = 113, $r = 114, $s = 115, $t = 116, $u = 117,
$v = 118, $w = 119, $x = 120, $y = 121, $z = 122; $v = 118, $w = 119, $x = 120, $y = 121, $z = 122;
var $LBRACE = 123; const $LBRACE = 123;
var $BAR = 124; const $BAR = 124;
var $RBRACE = 125; const $RBRACE = 125;
var $TILDE = 126; const $TILDE = 126;
var $NBSP = 160; const $NBSP = 160;
@ -251,7 +250,7 @@ export class Scanner {
return this.scanToken(); return this.scanToken();
} }
this.error('Unexpected character [$' + StringWrapper.fromCharCode(peek) + ']'); this.error(`Unexpected character [${StringWrapper.fromCharCode(peek)}]`);
return null; return null;
} }

View File

@ -34,13 +34,13 @@ function expectOperatorToken(token, index, operator) {
function expectNumberToken(token, index, n) { function expectNumberToken(token, index, n) {
expectToken(token, index); expectToken(token, index);
expect(token.isNumber()).toBe(true); expect(token.isNumber()).toBe(true);
expect(token.toNumber()).toBe(n); expect(token.toNumber()).toEqual(n);
} }
function expectStringToken(token, index, str) { function expectStringToken(token, index, str) {
expectToken(token, index); expectToken(token, index);
expect(token.isString()).toBe(true); expect(token.isString()).toBe(true);
expect(token.toString()).toBe(str); expect(token.toString()).toEqual(str);
} }
function expectIdentifierToken(token, index, identifier) { function expectIdentifierToken(token, index, identifier) {

View File

@ -1,6 +1,5 @@
import {CONSTRUCTOR, FROM} from 'traceur/src/syntax/PredefinedName'; import {CONSTRUCTOR, FROM} from 'traceur/src/syntax/PredefinedName';
import {EQUAL_EQUAL_EQUAL, OPEN_PAREN, CLOSE_PAREN, IMPORT, SEMI_COLON, STAR, OPEN_CURLY, CLOSE_CURLY, COMMA, AT, import {EQUAL_EQUAL_EQUAL, OPEN_PAREN, CLOSE_PAREN, IMPORT, SEMI_COLON, STAR, OPEN_CURLY, CLOSE_CURLY, COMMA, AT, EQUAL} from 'traceur/src/syntax/TokenType';
EQUAL, SINGLE_QUOTE} from 'traceur/src/syntax/TokenType';
import {ParseTreeWriter as JavaScriptParseTreeWriter} from 'traceur/src/outputgeneration/ParseTreeWriter'; import {ParseTreeWriter as JavaScriptParseTreeWriter} from 'traceur/src/outputgeneration/ParseTreeWriter';
@ -43,9 +42,13 @@ export class DartTreeWriter extends JavaScriptParseTreeWriter {
this.visitAny(tree.operand); this.visitAny(tree.operand);
this.writeSpace_(); this.writeSpace_();
} }
this.writeRaw_(SINGLE_QUOTE); this.writeRaw_('"');
this.visitList(tree.elements); this.visitList(tree.elements);
this.writeRaw_(SINGLE_QUOTE); this.writeRaw_('"');
}
visitTemplateLiteralPortion(tree) {
this.writeRaw_(tree.value.toString().replace(/('|")/g, "\\$&"));
} }