Commits

Stephen McKamey committed d6594cf

standardizing on single-quotes for JS strings

Comments (0)

Files changed (4)

duel-compiler/src/test/java/org/duelengine/duel/codegen/CodeDOMBuilderTests.java

 					new CodeThisReferenceExpression(),
 					"write",
 					new CodeVariableReferenceExpression(DuelContext.class, "context"),
-					new CodePrimitiveExpression(", { \"class\" : function(data, index, count, key) { return (barCSS(key)); } }, "))),
+					new CodePrimitiveExpression(", { 'class' : function(data, index, count, key) { return (barCSS(key)); } }, "))),
 				new CodeExpressionStatement(new CodeMethodInvokeExpression(
 					Void.class,
 					new CodeThisReferenceExpression(),
 					new CodeThisReferenceExpression(),
 					"write",
 					new CodeVariableReferenceExpression(DuelContext.class, "context"),
-					new CodePrimitiveExpression(", {\n\t\t\"class\" : function(data, index) { return (fooCSS(index)); },\n\t\tstyle : function(data) { return (customStyle(data)); }\n\t}, "))),
+					new CodePrimitiveExpression(", {\n\t\t'class' : function(data, index) { return (fooCSS(index)); },\n\t\tstyle : function(data) { return (customStyle(data)); }\n\t}, "))),
 				new CodeExpressionStatement(new CodeMethodInvokeExpression(
 					Void.class,
 					new CodeThisReferenceExpression(),

duel-runtime/src/main/java/org/duelengine/duel/DataEncoder.java

 		int start = 0,
 			length = data.length();
 
-		output.append('\"');
+		output.append('\'');
 
 		for (int i=start; i<length; i++) {
 			String escape;
 
 			char ch = data.charAt(i);
 			switch (ch) {
-				case '\"':
-					escape = "\\\"";
+				case '\'':
+					escape = "\\'";
 					break;
 				case '\\':
 					escape = "\\\\";
 			output.append(data, start, length);
 		}
 
-		output.append('\"');
+		output.append('\'');
 	}
 
 	/**
 			this.writeln(output, 0);
 			output.append("if (typeof ");
 			output.append(ns);
-			output.append(" === \"undefined\") {");
+			output.append(" === 'undefined') {");
 			this.writeln(output, 1);
 			output.append(ns);
 			output.append(" = {};");

duel-runtime/src/test/java/org/duelengine/duel/DataEncoderTests.java

 	public void writeNumberOverflowLongTest() throws IOException {
 		Object input = Long.MIN_VALUE;
 
-		String expected = "\"-9223372036854775808\"";
+		String expected = "'-9223372036854775808'";
 
 		StringBuilder output = new StringBuilder();
 		new DataEncoder().write(output, input);
 	public void writeNumberOverflowLongMaxTest() throws IOException {
 		Object input = Long.MAX_VALUE;
 
-		String expected = "\"9223372036854775807\"";
+		String expected = "'9223372036854775807'";
 
 		StringBuilder output = new StringBuilder();
 		new DataEncoder().write(output, input);
 	public void writeNumberOverflowLongBigTest() throws IOException {
 		Object input = 9223372036854775799L;
 
-		String expected = "\"9223372036854775799\"";
+		String expected = "'9223372036854775799'";
 
 		StringBuilder output = new StringBuilder();
 		new DataEncoder().write(output, input);
 	public void writeNumberOverflowLongSmallTest() throws IOException {
 		Object input = -9223372036854775799L;
 
-		String expected = "\"-9223372036854775799\"";
+		String expected = "'-9223372036854775799'";
 
 		StringBuilder output = new StringBuilder();
 		new DataEncoder().write(output, input);
 	public void writeStringEmptyTest() throws IOException {
 		Object input = "";
 
-		String expected = "\"\"";
+		String expected = "''";
 
 		StringBuilder output = new StringBuilder();
 		new DataEncoder().write(output, input);
 	public void writeStringSimpleTest() throws IOException {
 		Object input = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
 
-		String expected = "\"Lorem ipsum dolor sit amet, consectetur adipiscing elit.\"";
+		String expected = "'Lorem ipsum dolor sit amet, consectetur adipiscing elit.'";
 
 		StringBuilder output = new StringBuilder();
 		new DataEncoder().write(output, input);
 	public void writeStringEscapedTest() throws IOException {
 		Object input = "\\\b\f\n\r\t\u0123\u4567\u89AB\uCDEF\uabcd\uef4A\"";
 
-		String expected = "\"\\\\\\b\\f\\n\\r\\t\\u0123\\u4567\\u89AB\\uCDEF\\uABCD\\uEF4A\\\"\"";
+		String expected = "'\\\\\\b\\f\\n\\r\\t\\u0123\\u4567\\u89AB\\uCDEF\\uABCD\\uEF4A\"'";
 
 		StringBuilder output = new StringBuilder();
 		new DataEncoder().write(output, input);
 	public void writeArraySingleTest() throws IOException {
 		Object input = new String[] { "Test." };
 
-		String expected = "[\"Test.\"]";
+		String expected = "['Test.']";
 
 		StringBuilder output = new StringBuilder();
 		new DataEncoder().write(output, input);
 	public void writeArraySinglePrettyPrintTest() throws IOException {
 		Object input = new String[] { "Test." };
 
-		String expected = "[ \"Test.\" ]";
+		String expected = "[ 'Test.' ]";
 
 		StringBuilder output = new StringBuilder();
 		new DataEncoder("\n", "\t").write(output, input);
 	public void writeArrayMultipleTest() throws IOException {
 		Object input = Arrays.asList(false, null, true, 42, "Test");
 
-		String expected = "[false,null,true,42,\"Test\"]";
+		String expected = "[false,null,true,42,'Test']";
 
 		StringBuilder output = new StringBuilder();
 		new DataEncoder().write(output, input);
 			"\tnull,\n"+
 			"\ttrue,\n"+
 			"\t42,\n"+
-			"\t\"Test\"\n"+
+			"\t'Test'\n"+
 			"]";
 
 		StringBuilder output = new StringBuilder();
 				false, false
 			);
 
-		String expected = "{\"\":\"\",One:1,\"2\":\"Too\",\".T.H.R.E.E.\":3.141592653589793,$:null,\" white space \":true,\"false\":false}";
+		String expected = "{'':'',One:1,'2':'Too','.T.H.R.E.E.':3.141592653589793,$:null,' white space ':true,'false':false}";
 
 		StringBuilder output = new StringBuilder();
 		new DataEncoder().write(output, input);
 
 		String expected =
 			"{\n"+
-			"\t\"\" : \"\",\n"+
+			"\t'' : '',\n"+
 			"\tOne : 1,\n"+
-			"\t\"2\" : \"Too\",\n"+
-			"\t\".T.H.R.E.E.\" : 3.141592653589793,\n"+
+			"\t'2' : 'Too',\n"+
+			"\t'.T.H.R.E.E.' : 3.141592653589793,\n"+
 			"\t$ : null,\n"+
-			"\t\" white space \" : true,\n"+
-			"\t\"false\" : false\n"+
+			"\t' white space ' : true,\n"+
+			"\t'false' : false\n"+
 			"}";
 
 		StringBuilder output = new StringBuilder();

duel-runtime/src/test/java/org/duelengine/duel/SparseMapTests.java

 				"bar", true));
 
 		String expected =
-			"var simple = \"Hello\";\n"+
+			"var simple = 'Hello';\n"+
 			"var nested = {\n"+
 			"\tfoo : 42,\n"+
 			"\tbar : true\n"+
 			"nested.bar", true);
 
 		String expected =
-			"var simple = \"Hello\";\n"+
+			"var simple = 'Hello';\n"+
 			"var nested = nested || {};\n"+
 			"nested.foo = 42;\n"+
 			"nested.bar = true;\n";
 		input.putSparse("nested.baz", DuelData.asList(1, 2, 3));
 
 		String expected =
-			"var simple = \"Hello\";\n"+
+			"var simple = 'Hello';\n"+
 			"var nested = nested || {};\n"+
 			"nested.foo = 42;\n"+
 			"nested.bar = true;\n"+
 		input.putSparse("nested", DuelData.asList(1, 2, 3));
 
 		String expected =
-			"var simple = \"Hello\";\n"+
+			"var simple = 'Hello';\n"+
 			"var nested = [\n"+
 			"\t1,\n"+
 			"\t2,\n"+
 			"nested.bar", new Object());
 
 		String expected =
-			"var simple=\"Hello\";"+
+			"var simple='Hello';"+
 			"var nested=nested||{};"+
 			"nested.foo=null;"+
 			"nested.bar={};";
 			"nested.bar", new Object());
 
 		String expected =
-			"var simple = \"Hello\";\n"+
+			"var simple = 'Hello';\n"+
 			"var nested = nested || {};\n"+
 			"nested.foo = null;\n"+
 			"nested.bar = {};\n";
 		input.putSparse("nested.bar", true);
 
 		String expected =
-			"var simple = \"Hello\";\n"+
+			"var simple = 'Hello';\n"+
 			"var nested = {\n"+
 			"\tfoo : [\n"+
 			"\t\t1,\n"+
 			"nested.many=nested.many||{};"+
 			"nested.many.$levels={"+
 			"$:true,"+
-			"\"\":false,"+
+			"'':false,"+
 			"deep:["+
 			"1,"+
 			"2,"+
 			"nested.many = nested.many || {};\n"+
 			"nested.many.$levels = {\n"+
 			"\t$ : true,\n"+
-			"\t\"\" : false,\n"+
+			"\t'' : false,\n"+
 			"\tdeep : [\n"+
 			"\t\t1,\n"+
 			"\t\t2,\n"+