(core) Remove REPL code

Summary: Remove repl.py, REPLTab.js, some wiring code, CSS, and a test in testscript.json.

Test Plan: NA

Reviewers: dsagal

Reviewed By: dsagal

Differential Revision: https://phab.getgrist.com/D2923
This commit is contained in:
Alex Hall
2021-07-20 14:52:21 +02:00
parent 67aca9ccf6
commit 1f6e693b6e
12 changed files with 1 additions and 757 deletions

View File

@@ -2709,167 +2709,6 @@
}]
]
}, {
//------------------------------------------------------------------------
"TEST_CASE" : "eval_code",
//------------------------------------------------------------------------
"BODY": [
["LOAD_SAMPLE", "basic"],
["APPLY", {
"USER_ACTIONS": [
// Basic tests
["EvalCode", "print('cats')", null],
["EvalCode", "2 * 3 - 1 // 7 + 4", null],
// Exception
["EvalCode", "raise Exception('everything broke')", null],
// Incomplete structure
["EvalCode", "for x in range(1, 100):", null],
// Re-evaluation
["EvalCode", "print('cats')", 1],
["EvalCode", "print('dogs')", 1],
// Function definition
["EvalCode", "def foo(x):\n\treturn x * 10\n", null],
["EvalCode", "foo(10)", null]
],
"ACTIONS" : {
"stored" : [
["AddRecord", "_grist_REPL_Hist", 1,
{"code": "print('cats')", "errorText": "", "outputText": "cats\n"}],
["AddRecord", "_grist_REPL_Hist", 2,
{"code": "2 * 3 - 1 // 7 + 4", "errorText": "", "outputText": "10\n"}],
["AddRecord", "_grist_REPL_Hist", 3,
{"code": "raise Exception('everything broke')", "errorText": "Traceback (most recent call last):\n File \"<input>\", line 1, in <module>\nException: everything broke\n", "outputText": ""}],
["UpdateRecord", "_grist_REPL_Hist", 1,
{"code": "print('cats')", "errorText": "", "outputText": "cats\n"}],
["UpdateRecord", "_grist_REPL_Hist", 1,
{"code": "print('dogs')", "errorText": "", "outputText": "dogs\n"}],
["AddRecord", "_grist_REPL_Hist", 4,
{"code": "def foo(x):\n\treturn x * 10\n", "errorText": "", "outputText": ""}],
["AddRecord", "_grist_REPL_Hist", 5,
{"code": "foo(10)", "errorText": "", "outputText": "100\n"}]
],
"direct": [true, true, true, true, true, true, true],
"undo" : [
["RemoveRecord", "_grist_REPL_Hist", 1],
["RemoveRecord", "_grist_REPL_Hist", 2],
["RemoveRecord", "_grist_REPL_Hist", 3],
["UpdateRecord", "_grist_REPL_Hist", 1,
{"code": "print('cats')", "errorText": "", "outputText": "cats\n"}],
["UpdateRecord", "_grist_REPL_Hist", 1,
{"code": "print('cats')", "errorText": "", "outputText": "cats\n"}],
["RemoveRecord", "_grist_REPL_Hist", 4],
["RemoveRecord", "_grist_REPL_Hist", 5]
],
"retValue" : [true,true,true,false,true,true,true,true]
}
}],
["APPLY", {
"USER_ACTIONS": [
// Access to usercode before and after re-generation
["EvalCode", "list(map(str, Students.all.firstName))", null],
["UpdateRecord", "Students", 1, {"firstName": "2e6"}],
["ModifyColumn", "Students", "firstName", { "type" : "Numeric" }],
["EvalCode", "list(Students.all.firstName)", 6],
// Make sure that other tables are still usable as well after a schema change.
["EvalCode", "len(Schools.all)", 6]
],
"ACTIONS": {
"stored": [
["AddRecord", "_grist_REPL_Hist", 6,
{"code": "list(map(str, Students.all.firstName))", "errorText": "", "outputText": "['Barack', 'George W', 'Bill', 'George H', 'Ronald', 'Jimmy', 'Gerald']\n"}],
["UpdateRecord", "Students", 1, {"firstName": "2e6"}],
["ModifyColumn", "Students", "firstName", {"type": "Numeric"}],
["UpdateRecord", "Students", 1, {"firstName": 2e6}],
["UpdateRecord", "_grist_Tables_column", 1, {"type": "Numeric"}],
["UpdateRecord", "_grist_REPL_Hist", 6, {"code": "list(Students.all.firstName)",
"errorText": "",
"outputText": "[2000000.0, AltText('George W'), AltText('Bill'), AltText('George H'), AltText('Ronald'), AltText('Jimmy'), AltText('Gerald')]\n"}],
["UpdateRecord", "_grist_REPL_Hist", 6,
{"code": "len(Schools.all)", "errorText": "", "outputText": "6\n"}],
["BulkUpdateRecord", "Students", [1, 2, 3, 4, 5, 6, 8], {
"fullName": [["E", "TypeError"], ["E","TypeError"], ["E","TypeError"],
["E","TypeError"], ["E","TypeError"], ["E","TypeError"], ["E","TypeError"]]
}],
["BulkUpdateRecord", "Students", [1, 2, 3, 4, 5, 6, 8], {
"fullNameLen": [["E","TypeError"], ["E","TypeError"], ["E","TypeError"],
["E","TypeError"], ["E","TypeError"], ["E","TypeError"], ["E","TypeError"]]
}]
],
"direct": [true, true, true, false, true, true, true, false, false],
"undo": [
["RemoveRecord", "_grist_REPL_Hist", 6],
["UpdateRecord", "Students", 1, {"firstName": "Barack"}],
["UpdateRecord", "Students", 1, {"firstName": "2e6"}],
["ModifyColumn", "Students", "firstName", {"type": "Text"}],
["UpdateRecord", "_grist_Tables_column", 1, {"type": "Text"}],
["UpdateRecord", "_grist_REPL_Hist", 6, {"code": "list(map(str, Students.all.firstName))",
"errorText": "", "outputText": "['Barack', 'George W', 'Bill', 'George H', 'Ronald', 'Jimmy', 'Gerald']\n"}],
["UpdateRecord", "_grist_REPL_Hist", 6, {"code": "list(Students.all.firstName)",
"errorText": "",
"outputText": "[2000000.0, AltText('George W'), AltText('Bill'), AltText('George H'), AltText('Ronald'), AltText('Jimmy'), AltText('Gerald')]\n"}],
["BulkUpdateRecord", "Students", [1, 2, 3, 4, 5, 6, 8],
{"fullName": ["Barack Obama", "George W Bush", "Bill Clinton", "George H Bush", "Ronald Reagan", "Jimmy Carter", "Gerald Ford"]}],
["BulkUpdateRecord", "Students", [1, 2, 3, 4, 5, 6, 8],
{"fullNameLen": [12, 13, 12, 13, 13, 12, 11]}]
],
"retValue": [true,null,null,true,true]
}
}],
["APPLY", {
"USER_ACTIONS": [
// Syntax Error
["EvalCode", "not correct c", null],
// Other continuations
["EvalCode", "map(filter, ", null],
["EvalCode", "[1,2,3,", null],
// sys.exit
["EvalCode", "import sys", null],
["EvalCode", "sys.exit(0)", null],
// User reassignment of sys.stdout/sys.stderr
["EvalCode", "sys.stdout = None", null],
["EvalCode", "setattr(sys.stdout, 'getvalue', lambda : 2)", null],
["EvalCode", "def foo():\n global stdout\n exec('stdout = 2')\n", null],
["EvalCode", "setattr(sys.stderr, 'close', foo)", null]
],
"ACTIONS": {
"stored": [
["AddRecord", "_grist_REPL_Hist", 7,
{"code": "not correct c", "errorText": " File \"<input>\", line 1\n not correct c\n ^\nSyntaxError: invalid syntax\n", "outputText": ""}],
["AddRecord", "_grist_REPL_Hist", 8,
{"code": "import sys", "errorText": "", "outputText": ""}],
["AddRecord", "_grist_REPL_Hist", 9,
{"code": "sys.exit(0)", "errorText": "Traceback (most recent call last):\n File \"<input>\", line 1, in <module>\nSystemExit: 0\n", "outputText": ""}],
["AddRecord", "_grist_REPL_Hist", 10,
{"code": "sys.stdout = None", "errorText": "", "outputText": ""}],
["AddRecord", "_grist_REPL_Hist", 11,
{"code": "setattr(sys.stdout, 'getvalue', lambda : 2)", "errorText": "", "outputText": 2}],
["AddRecord", "_grist_REPL_Hist", 12,
{"code": "def foo():\n global stdout\n exec('stdout = 2')\n", "errorText": "", "outputText": ""}],
["AddRecord", "_grist_REPL_Hist", 13,
{"code": "setattr(sys.stderr, 'close', foo)", "errorText": "", "outputText": ""}]
],
"direct": [true, true, true, true, true, true, true],
"undo": [
["RemoveRecord", "_grist_REPL_Hist", 7],
["RemoveRecord", "_grist_REPL_Hist", 8],
["RemoveRecord", "_grist_REPL_Hist", 9],
["RemoveRecord", "_grist_REPL_Hist", 10],
["RemoveRecord", "_grist_REPL_Hist", 11],
["RemoveRecord", "_grist_REPL_Hist", 12],
["RemoveRecord", "_grist_REPL_Hist", 13]
],
"retValue" : [true,false,false,true,true,true,true,true,true ]
}
}]
]
}, {
//------------------------------------------------------------------------
"TEST_CASE" : "reserved_keywords",
//------------------------------------------------------------------------