Copying and reducing test suite for Compact profile.
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
// Copyright 2014 Samsung Electronics Co., Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
assert(typeof Object.getPrototypeOf(Object) == "function" &&
|
||||
Object.length == 1);
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright 2014 Samsung Electronics Co., Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
assert(typeof Object.prototype == "object");
|
||||
@@ -0,0 +1,33 @@
|
||||
// Copyright 2014 Samsung Electronics Co., Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
|
||||
writable = false;
|
||||
enumerable = false;
|
||||
configurable = false;
|
||||
|
||||
Object.prototype = "qwerty";
|
||||
if (Object.prototype === "qwerty")
|
||||
writable = true;
|
||||
|
||||
for (prop in Object)
|
||||
{
|
||||
if (Object[prop] == "qwerty")
|
||||
enumerable = true;
|
||||
}
|
||||
|
||||
if (delete Object.prototype)
|
||||
configurable = true;
|
||||
|
||||
assert(writable || enumerable || configurable);
|
||||
@@ -0,0 +1,28 @@
|
||||
// Copyright 2014 Samsung Electronics Co., Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
var object = {
|
||||
prop1: Number,
|
||||
prop2: String,
|
||||
prop3: true,
|
||||
prop4: 0
|
||||
}
|
||||
|
||||
var keys = Object.keys(object);
|
||||
|
||||
assert(keys[0] == "prop1" &&
|
||||
keys[1] == "prop2" &&
|
||||
keys[2] == "prop3" &&
|
||||
keys[3] == "prop4");
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
// Copyright 2014 Samsung Electronics Co., Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
var a = {
|
||||
field: Number
|
||||
}
|
||||
|
||||
assert(Object.getPrototypeOf(a) == Object.getPrototypeOf(Object()));
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright 2014 Samsung Electronics Co., Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
var object1 = {
|
||||
field1: 5,
|
||||
field2: "qwe",
|
||||
field3: true
|
||||
}
|
||||
|
||||
var object2 = {
|
||||
field1: 5,
|
||||
field2: "qwe",
|
||||
field3: true
|
||||
}
|
||||
|
||||
Object.freeze(object1);
|
||||
|
||||
assert(Object.isExtensible(object1) && !Object.isExtensible(object2));
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright 2014 Samsung Electronics Co., Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
var a = {
|
||||
foo: function () {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
desc = Object.getOwnPropertyDescriptor(a, "foo");
|
||||
|
||||
assert(desc instanceof Object);
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright 2014 Samsung Electronics Co., Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
var object1 = {
|
||||
field1: 5,
|
||||
field2: "qwe",
|
||||
field3: true
|
||||
}
|
||||
|
||||
var object2 = {
|
||||
field1: 5,
|
||||
field2: "qwe",
|
||||
field3: true
|
||||
}
|
||||
|
||||
Object.freeze(object1);
|
||||
|
||||
assert(Object.isFrozen(object1) && !Object.isFrozen(object2));
|
||||
@@ -0,0 +1,31 @@
|
||||
// Copyright 2014 Samsung Electronics Co., Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
var a = {
|
||||
prop1: Number,
|
||||
prop2: String,
|
||||
foo: function () {
|
||||
return 1;
|
||||
},
|
||||
bar: function () {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
names = Object.getOwnPropertyNames(a);
|
||||
|
||||
assert(names instanceof Array &&
|
||||
names[0] === "prop1" &&
|
||||
names[1] === "prop2" &&
|
||||
names[2] === "foo" &&
|
||||
names[3] === "bar");
|
||||
@@ -0,0 +1,21 @@
|
||||
// Copyright 2014 Samsung Electronics Co., Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
var a = new String("qwe");
|
||||
names = Object.getOwnPropertyNames(a);
|
||||
assert(names instanceof Array &&
|
||||
names[0] === "0" &&
|
||||
names[1] === "1" &&
|
||||
names[2] === "2" &&
|
||||
names[3] === "length");
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright 2014 Samsung Electronics Co., Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
var object1 = {
|
||||
field1: 5,
|
||||
field2: "qwe",
|
||||
field3: true
|
||||
}
|
||||
|
||||
var object2 = {
|
||||
field1: 5,
|
||||
field2: "qwe",
|
||||
field3: true
|
||||
}
|
||||
|
||||
Object.seal(object1);
|
||||
|
||||
assert(Object.isSealed(object1) && !Object.isSealed(object2));
|
||||
@@ -0,0 +1,26 @@
|
||||
// Copyright 2014 Samsung Electronics Co., Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
var veryUsefulObject = {
|
||||
}
|
||||
|
||||
Object.preventExtensions(veryUsefulObject);
|
||||
|
||||
veryUsefulObject.property = "qwerty";
|
||||
|
||||
veryUsefulObject.method = function () {
|
||||
return "asdf";
|
||||
}
|
||||
|
||||
assert(veryUsefulObject.property && veryUsefulObject.method());
|
||||
@@ -0,0 +1,28 @@
|
||||
// Copyright 2014 Samsung Electronics Co., Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
var niceObject = {
|
||||
niceProp1: String,
|
||||
niceProp2: Number,
|
||||
niceMeth: function () {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
var someElseObject = {
|
||||
prop1: Boolean,
|
||||
prop2: Number
|
||||
}
|
||||
var niceChild = Object.create(niceObject, someElseObject);
|
||||
|
||||
assert(Object.getPrototypeOf(niceChild) === niceObject);
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright 2014 Samsung Electronics Co., Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
var a = new String("qwe"); //I'm not a string I'm Object-String. It's OK.
|
||||
var someElseObject = {
|
||||
prop1: Boolean,
|
||||
prop2: Number
|
||||
}
|
||||
var niceChild = Object.create(a, someElseObject);
|
||||
|
||||
assert(Object.getPrototypeOf(niceChild) === a);
|
||||
@@ -0,0 +1,19 @@
|
||||
// Copyright 2014 Samsung Electronics Co., Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
var a = {}
|
||||
var someElseObject = undefined;
|
||||
var childObject = Object.create(a, someElseObject); //nothing is inherited
|
||||
|
||||
assert(Object.getPrototypeOf(childObject) === a && Object.getOwnPropertyNames(childObject).length == 0);
|
||||
@@ -0,0 +1,49 @@
|
||||
// Copyright 2014 Samsung Electronics Co., Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
var emptyObject = {}
|
||||
|
||||
var propertyDescriptor = {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
get: function () {
|
||||
return myProperty;
|
||||
},
|
||||
set: function (newValue) {
|
||||
myProperty = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
Object.defineProperty(emptyObject, 'myProperty', propertyDescriptor);
|
||||
|
||||
var checkGetSet = false;
|
||||
var isEnumerable = false;
|
||||
var isConfigurable = false;
|
||||
|
||||
emptyObject.myProperty = "foobar";
|
||||
if (emptyObject.myProperty == "foobar")
|
||||
checkGetSet = true;
|
||||
|
||||
for (p in emptyObject) {
|
||||
if (emptyObject[p] == "foobar") {
|
||||
isEnumerable = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (delete emptyObject.myProperty)
|
||||
isConfigurable = true;
|
||||
|
||||
assert(checkGetSet && isEnumerable && isConfigurable);
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright 2014 Samsung Electronics Co., Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
var object = {
|
||||
prop1: "qwerty",
|
||||
prop2: 123,
|
||||
}
|
||||
|
||||
Object.freeze(object);
|
||||
|
||||
object.prop1 = "asdf";
|
||||
object.prop3 = true;
|
||||
|
||||
assert(!(object.prop1 === "asdf") && !delete object.prop2 && !object.prop3);
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright 2014 Samsung Electronics Co., Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
var object = {
|
||||
prop1: Number,
|
||||
prop2: String,
|
||||
prop3: Boolean
|
||||
}
|
||||
|
||||
Object.seal(object);
|
||||
|
||||
check = delete object.prop1 || delete object.prop2 || delete object.prop3;
|
||||
|
||||
object.prop4 = 3;
|
||||
|
||||
check = check || Boolean(object.prop4);
|
||||
|
||||
assert(!check);
|
||||
@@ -0,0 +1,53 @@
|
||||
// Copyright 2014 Samsung Electronics Co., Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
var emptyObject = {}
|
||||
|
||||
var properties = {
|
||||
prop1: {
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: false,
|
||||
value: "I'm prop1"
|
||||
},
|
||||
prop2: {
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: false,
|
||||
value: "I'm prop2"
|
||||
}
|
||||
}
|
||||
|
||||
var isEnumerable = true;
|
||||
var isConfigurable = true;
|
||||
var isWritable = false;
|
||||
|
||||
Object.defineProperties(emptyObject, properties);
|
||||
|
||||
emptyObject.prop1 = "hello";
|
||||
emptyObject.prop2 = "world";
|
||||
|
||||
if (emptyObject.prop1 === "hello" && emptyObject.prop2 == "world")
|
||||
isWritable = true;
|
||||
|
||||
for (p in emptyObject) {
|
||||
if (emptyObject[p] === "hello")
|
||||
isEnumerable = !isEnumerable;
|
||||
else if (emptyObject[p] === "world")
|
||||
isEnumerable = !isEnumerable;
|
||||
}
|
||||
|
||||
isConfigurable = delete emptyObject.prop1 && delete emptyObject.prop2
|
||||
|
||||
assert(isWritable && isEnumerable && !isConfigurable);
|
||||
@@ -0,0 +1,44 @@
|
||||
// Copyright 2014 Samsung Electronics Co., Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
var emptyObject = {}
|
||||
|
||||
var propertyDescriptor = {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
value: "hello!",
|
||||
writable: true
|
||||
}
|
||||
|
||||
Object.defineProperty(emptyObject, 'myProperty', propertyDescriptor);
|
||||
|
||||
var isWritable = false;
|
||||
var isEnumerable = false;
|
||||
var isConfigurable = false;
|
||||
|
||||
emptyObject.myProperty = "foobar";
|
||||
if (emptyObject.myProperty == "foobar")
|
||||
isWritable = true;
|
||||
|
||||
for (p in emptyObject) {
|
||||
if (emptyObject[p] == "foobar") {
|
||||
isEnumerable = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (delete emptyObject.myProperty)
|
||||
isConfigurable = true;
|
||||
|
||||
assert(isWritable && isEnumerable && isConfigurable);
|
||||
@@ -0,0 +1,52 @@
|
||||
// Copyright 2014 Samsung Electronics Co., Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
var emptyObject = {}
|
||||
|
||||
var propertyDescriptor = {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
value: "hello!",
|
||||
writable: true
|
||||
}
|
||||
|
||||
Object.defineProperty(emptyObject, 'myProperty', propertyDescriptor);
|
||||
|
||||
var newPropertyDescriptor = {
|
||||
enumerable: false,
|
||||
configurable: false,
|
||||
writable: false
|
||||
}
|
||||
|
||||
Object.defineProperty(emptyObject, 'myProperty', newPropertyDescriptor); //change properties of property
|
||||
|
||||
var isWritable = false;
|
||||
var isEnumerable = false;
|
||||
var isConfigurable = false;
|
||||
|
||||
emptyObject.myProperty = "foobar";
|
||||
if (emptyObject.myProperty == "foobar")
|
||||
isWritable = true;
|
||||
|
||||
for (p in emptyObject) {
|
||||
if (emptyObject[p] == "foobar") {
|
||||
isEnumerable = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (delete emptyObject.myProperty)
|
||||
isConfigurable = true;
|
||||
|
||||
assert(isWritable || isEnumerable || isConfigurable);
|
||||
Reference in New Issue
Block a user