Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: test/cctest/asmjs/test-asm-typer.cc

Issue 2435823002: [V8][asm.js] Adds support to global const variables. (Closed)
Patch Set: Addresses comments. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/asmjs/asm-typer.cc ('k') | test/mjsunit/asm/asm-validation.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <cstring> 5 #include <cstring>
6 #include <functional> 6 #include <functional>
7 #include <iostream> 7 #include <iostream>
8 #include <memory> 8 #include <memory>
9 9
10 #include "src/asmjs/asm-typer.h" 10 #include "src/asmjs/asm-typer.h"
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 } 498 }
499 } 499 }
500 } 500 }
501 501
502 TEST(ErrorsInGlobalVariableDefinition) { 502 TEST(ErrorsInGlobalVariableDefinition) {
503 const struct { 503 const struct {
504 const char* decl; 504 const char* decl;
505 const char* error_message; 505 const char* error_message;
506 } kTests[] = { 506 } kTests[] = {
507 {"var v;", "Global variable missing initializer"}, 507 {"var v;", "Global variable missing initializer"},
508 {"var v = uninitialized;", "Invalid global variable initializer"}, 508 {"var v = uninitialized;", "Undeclared identifier in global"},
509 {"var v = 'use asm';", "type annotation - forbidden literal"}, 509 {"var v = 'use asm';", "type annotation - forbidden literal"},
510 {"var v = 4294967296;", " - forbidden literal"}, 510 {"var v = 4294967296;", " - forbidden literal"},
511 {"var v = not_fround;", "Invalid global variable initializer"}, 511 {"var v = not_fround;", "initialize a global must be a const"},
512 {"var v = not_fround(1);", "expected call fround(literal)"}, 512 {"var v = not_fround(1);", "expected call fround(literal)"},
513 {"var v = __fround__(1.0);", "expected call fround(literal)"}, 513 {"var v = __fround__(1.0);", "expected call fround(literal)"},
514 {"var v = fround(1.0, 1.0);", "expected call fround(literal)"}, 514 {"var v = fround(1.0, 1.0);", "expected call fround(literal)"},
515 {"var v = fround(not_fround);", "literal argument for call to fround"}, 515 {"var v = fround(not_fround);", "literal argument for call to fround"},
516 {"var v = i?0:1;", "Invalid global variable initializer"},
516 {"var v = stdlib.nan", "Invalid import"}, 517 {"var v = stdlib.nan", "Invalid import"},
517 {"var v = stdlib.Math.nan", "Invalid import"}, 518 {"var v = stdlib.Math.nan", "Invalid import"},
518 {"var v = stdlib.Mathh.E", "Invalid import"}, 519 {"var v = stdlib.Mathh.E", "Invalid import"},
519 {"var v = stdlib.Math", "Invalid import"}, 520 {"var v = stdlib.Math", "Invalid import"},
520 {"var v = Stdlib.Math.E", "Invalid import"}, 521 {"var v = Stdlib.Math.E", "Invalid import"},
521 {"var v = stdlib.Math.E[0]", "Invalid import"}, 522 {"var v = stdlib.Math.E[0]", "Invalid import"},
522 {"var v = stdlibb.NaN", "Invalid import"}, 523 {"var v = stdlibb.NaN", "Invalid import"},
523 {"var v = ffi.NaN[0]", "Invalid import"}, 524 {"var v = ffi.NaN[0]", "Invalid import"},
524 {"var v = heap.NaN[0]", "Invalid import"}, 525 {"var v = heap.NaN[0]", "Invalid import"},
525 {"var v = ffi.foo * 2.0;", "unrecognized annotation"}, 526 {"var v = ffi.foo * 2.0;", "unrecognized annotation"},
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 " var c = 0; var c = 1.0;\n" 782 " var c = 0; var c = 1.0;\n"
782 "}\n", 783 "}\n",
783 "Redeclared local"}, 784 "Redeclared local"},
784 {"function f(b, a) {\n" 785 {"function f(b, a) {\n"
785 " b = +b;\n" 786 " b = +b;\n"
786 " a = a|0;\n" 787 " a = a|0;\n"
787 " f();\n" 788 " f();\n"
788 " var c = 0;\n" 789 " var c = 0;\n"
789 "}\n", 790 "}\n",
790 "Local variable missing initializer in asm.js module"}, 791 "Local variable missing initializer in asm.js module"},
792 {"function f(a) {\n"
793 " a = a|0;\n"
794 " var x = a;\n"
795 "}\n",
796 "variable declaration initializer must be const"},
797 {"function f() {\n"
798 " var x = 1+i;\n"
799 "}\n",
800 "should be a literal, const, or fround(literal"},
801 {"function f() {\n"
802 " var x = a;\n"
803 "}\n",
804 "Undeclared identifier in variable declaration initializer"},
791 {"function f() {\n" 805 {"function f() {\n"
792 " function ff() {}\n" 806 " function ff() {}\n"
793 "}\n", 807 "}\n",
794 "Functions may only define inner variables"}, 808 "Functions may only define inner variables"},
795 {"function f() {\n" 809 {"function f() {\n"
796 " return a+1;\n" 810 " return a+1;\n"
797 "}\n", 811 "}\n",
798 "Invalid return type annotation"}, 812 "Invalid return type annotation"},
799 {"function f() {\n" 813 {"function f() {\n"
800 " return ~~x;\n" 814 " return ~~x;\n"
801 "}\n", 815 "}\n",
802 "Invalid return type annotation"}, 816 "Invalid return type annotation"},
803 {"function f() {\n" 817 {"function f() {\n"
804 " return d();\n" 818 " return d();\n"
805 "}\n", 819 "}\n",
806 "Invalid function call in return statement"}, 820 "Invalid function call in return statement"},
807 {"function f() {\n" 821 {"function f() {\n"
808 " return 'use asm';\n" 822 " return 'use asm';\n"
809 "}\n", 823 "}\n",
810 "Invalid literal in return statement"}, 824 "Invalid literal in return statement"},
811 {"function f() {\n" 825 {"function f() {\n"
812 " return 2147483648;\n" 826 " return 2147483648;\n"
813 "}\n", 827 "}\n",
814 "Invalid literal in return statement"}, 828 "Invalid literal in return statement"},
829 {"function f(a) {\n"
830 " a = a|0;\n"
831 " return a;\n"
832 "}\n",
833 "in return statement is not const"},
834 {"function f() {\n"
835 " return a;\n"
836 "}\n",
837 "Undeclared identifier in return statement"},
838 {"function f() {\n"
839 " return i?0:1;\n"
840 "}\n",
841 "Invalid return type expression"},
815 {"function f() {\n" 842 {"function f() {\n"
816 " return stdlib.Math.E;" 843 " return stdlib.Math.E;"
817 "}\n", 844 "}\n",
818 "Invalid return type expression"}, 845 "Invalid return type expression"},
819 {"function f() {\n" 846 {"function f() {\n"
820 " return E[0];" 847 " return E[0];"
821 "}\n", 848 "}\n",
822 "Invalid return type expression"}, 849 "Invalid return type expression"},
823 {"function I() {}\n", "Identifier redefined as function"}, 850 {"function I() {}\n", "Identifier redefined as function"},
824 {"function foo() {}\n", "Identifier redefined as function"}, 851 {"function foo() {}\n", "Identifier redefined as function"},
(...skipping 1167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1992 for (size_t ii = 0; ii < arraysize(kTests); ++ii) { 2019 for (size_t ii = 0; ii < arraysize(kTests); ++ii) {
1993 if (!ValidationOf(Module(kTests[ii])) 2020 if (!ValidationOf(Module(kTests[ii]))
1994 ->FailsWithMessage("Can't assign to immutable symbol")) { 2021 ->FailsWithMessage("Can't assign to immutable symbol")) {
1995 std::cerr << "Test:\n" << kTests[ii]; 2022 std::cerr << "Test:\n" << kTests[ii];
1996 CHECK(false); 2023 CHECK(false);
1997 } 2024 }
1998 } 2025 }
1999 } 2026 }
2000 2027
2001 } // namespace 2028 } // namespace
OLDNEW
« no previous file with comments | « src/asmjs/asm-typer.cc ('k') | test/mjsunit/asm/asm-validation.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698