From 5e217d531e2f0085ef54bc176365fa92ae4ea62c Mon Sep 17 00:00:00 2001
From: Katie Broida <kbroida@gmail.com>
Date: Tue, 14 Aug 2018 13:50:37 -0400
Subject: [PATCH] Add private methods test templates

---
 .../default/cls-private-decl-inst.template    | 26 +++++++++++
 .../default/cls-private-decl-static.template  | 46 +++++++++++++++++++
 .../default/cls-private-expr-inst.template    | 45 ++++++++++++++++++
 .../default/cls-private-expr-static.template  | 45 ++++++++++++++++++
 4 files changed, 162 insertions(+)
 create mode 100644 src/accessor-names/default/cls-private-decl-inst.template
 create mode 100644 src/accessor-names/default/cls-private-decl-static.template
 create mode 100644 src/accessor-names/default/cls-private-expr-inst.template
 create mode 100644 src/accessor-names/default/cls-private-expr-static.template

diff --git a/src/accessor-names/default/cls-private-decl-inst.template b/src/accessor-names/default/cls-private-decl-inst.template
new file mode 100644
index 0000000000..ba8a7c25ea
--- /dev/null
+++ b/src/accessor-names/default/cls-private-decl-inst.template
@@ -0,0 +1,26 @@
+// Copyright (C) 2017 Mike Pennisi. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+path: language/statements/class/accessor-name-inst-
+name: Class declaration, instance method
+esid: sec-runtime-semantics-classdefinitionevaluation
+es6id: 14.5.14
+info: |
+  [...]
+  21. For each ClassElement m in order from methods
+      a. If IsStatic of m is false, then
+         i. Let status be the result of performing PropertyDefinitionEvaluation
+            for m with arguments proto and false.
+---*/
+
+var stringSet;
+
+class C {
+  get /*{ declareWith }*/() { return 'get string'; }
+  set /*{ declareWith }*/(param) { stringSet = param; }
+}
+
+assert.sameValue(C.prototype[/*{ referenceWith }*/], 'get string');
+
+C.prototype[/*{ referenceWith }*/] = 'set string';
+assert.sameValue(stringSet, 'set string');
diff --git a/src/accessor-names/default/cls-private-decl-static.template b/src/accessor-names/default/cls-private-decl-static.template
new file mode 100644
index 0000000000..bb7f71b3ae
--- /dev/null
+++ b/src/accessor-names/default/cls-private-decl-static.template
@@ -0,0 +1,46 @@
+// Copyright (C) 2018 Katie Broida. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+path: language/statements/class/private-accessor-name-static-
+name: Class declaration, static method
+esid: #prod-MethodDefinition
+info: |
+  [...]
+  MethodDefinition[Yield, Await]:
+      PropertyNameClassElementName [?Yield, ?Await](
+        UniqueFormalParameters [~Yield, ~Await] ) {
+        FunctionBody [~Yield, ~Await] }
+      AsyncMethod[?Yield, ?Await]
+        get PropertyName ClassElementName [?Yield, ?Await] (){
+          FunctionBody [~Yield, ~Await] }
+        set PropertyNameClassElementName [?Yield, ?Await] (
+          PropertySetParameterList ) { FunctionBody [~Yield, ~Await] }
+      AsyncMethod [Yield, Await]:
+        async [no LineTerminator here] PropertyName
+          ClassElementName[?Yield, ?Await](
+          UniqueFormalParameters[~Yield, +Await] ) { AsyncFunctionBody }
+
+---*/
+
+var stringSet;
+
+class C {
+  static get #/*{ declareWith }*/() { return 'get string'; }
+  static set #/*{ declareWith }*/(param) { stringSet = param; }
+
+  static getPrivateReference() {
+    return this.#/*{ referenceWith }*/;
+  }
+
+  static setPrivateReference(value) {
+    this.#/*{ referenceWith }*/ = value;
+  }
+}
+
+var inst = C();
+
+assert.sameValue(inst.getPrivateReference(), 'get string');
+
+inst.setPrivateReference('set string');
+assert.sameValue(stringSet, 'set string');
+
diff --git a/src/accessor-names/default/cls-private-expr-inst.template b/src/accessor-names/default/cls-private-expr-inst.template
new file mode 100644
index 0000000000..1a14db69f1
--- /dev/null
+++ b/src/accessor-names/default/cls-private-expr-inst.template
@@ -0,0 +1,45 @@
+// Copyright (C) 2018 Katie Broida. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+path: language/expressions/class/private-accessor-name-inst-
+name: Class expression, instance private method
+esid: #prod-MethodDefinition
+info: |
+  [...]
+    MethodDefinition[Yield, Await]:
+      PropertyNameClassElementName [?Yield, ?Await](
+        UniqueFormalParameters [~Yield, ~Await] ) {
+        FunctionBody [~Yield, ~Await] }
+      AsyncMethod[?Yield, ?Await]
+        get PropertyName ClassElementName [?Yield, ?Await] (){
+          FunctionBody [~Yield, ~Await] }
+        set PropertyNameClassElementName [?Yield, ?Await] ( 
+          PropertySetParameterList ) { FunctionBody [~Yield, ~Await] }
+      AsyncMethod [Yield, Await]:
+        async [no LineTerminator here] PropertyName
+          ClassElementName[?Yield, ?Await](
+          UniqueFormalParameters[~Yield, +Await] ) { AsyncFunctionBody }
+
+---*/
+
+var stringSet;
+
+var C = class {
+  get #/*{ declareWith }*/() { return 'get string'; }
+  set #/*{ declareWith }*/(param) { stringSet = param; }
+
+  getPrivateReference() {
+    return this.#/*{ referenceWith }*/;
+  }
+
+  setPrivateReference(value) {
+    this.#/*{ referenceWith }*/ = value;
+  }
+};
+
+var inst = C();
+
+assert.sameValue(inst.getPrivateReference(), 'get string');
+
+inst.setPrivateReference('set string');
+assert.sameValue(stringSet, 'set string');
diff --git a/src/accessor-names/default/cls-private-expr-static.template b/src/accessor-names/default/cls-private-expr-static.template
new file mode 100644
index 0000000000..e004113c28
--- /dev/null
+++ b/src/accessor-names/default/cls-private-expr-static.template
@@ -0,0 +1,45 @@
+// Copyright (C) 2018 Katie Broida. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+path: language/expressions/class/private-accessor-name-static-
+name: Class expression, static private method
+esid: #prod-MethodDefinition
+info: |
+  [...]
+  MethodDefinition[Yield, Await]:
+      PropertyNameClassElementName [?Yield, ?Await](
+        UniqueFormalParameters [~Yield, ~Await] ) {
+        FunctionBody [~Yield, ~Await] }
+      AsyncMethod[?Yield, ?Await]
+        get PropertyName ClassElementName [?Yield, ?Await] (){
+          FunctionBody [~Yield, ~Await] }
+        set PropertyNameClassElementName [?Yield, ?Await] ( 
+          PropertySetParameterList ) { FunctionBody [~Yield, ~Await] }
+      AsyncMethod [Yield, Await]:
+        async [no LineTerminator here] PropertyName
+          ClassElementName[?Yield, ?Await](
+          UniqueFormalParameters[~Yield, +Await] ) { AsyncFunctionBody }
+
+---*/
+
+var stringSet;
+
+var C = class {
+  static get #/*{ declareWith }*/() { return 'get string'; }
+  static set #/*{ declareWith }*/(param) { stringSet = param; }
+
+  static getPrivateReference() {
+    return this.#/*{ referenceWith }*/;
+  }
+
+  static setPrivateReference(value) {
+    this.#/*{ referenceWith }*/ = value;
+  }
+};
+
+var inst = C();
+
+assert.sameValue(inst.getPrivateReference(), 'get string');
+
+inst.setPrivateReference('set string');
+assert.sameValue(stringSet, 'set string');
-- 
GitLab