diff options
author | Valerie R Young <valerie@bocoup.com> | 2017-10-30 00:34:05 -0400 |
---|---|---|
committer | Leo Balter <leonardo.balter@gmail.com> | 2017-11-03 14:52:46 -0400 |
commit | 214e9969d5d1cb8c019f40d56bb877d28740e0a7 (patch) | |
tree | 70a8c5704f7e98b7dc5a3680792c5c546310461b /src/class-fields/private-names.case | |
parent | ce203360b10186ff9497019af483ff56c17b72b4 (diff) | |
download | qtdeclarative-testsuites-214e9969d5d1cb8c019f40d56bb877d28740e0a7.tar.gz |
class fields: added tests for privatename production
Diffstat (limited to 'src/class-fields/private-names.case')
-rw-r--r-- | src/class-fields/private-names.case | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/class-fields/private-names.case b/src/class-fields/private-names.case new file mode 100644 index 000000000..6987bcd7b --- /dev/null +++ b/src/class-fields/private-names.case @@ -0,0 +1,50 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: static literal private names +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName +template: default +---*/ + +//- fields +#x; #y +//- privateinspectionfunctions + x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +//- assertions + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10"); |