| // Copyright 2019 the V8 project authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| let lf = new Intl.ListFormat("en"); |
| assertDoesNotThrow(() => lf.format(['a','b','c'])); |
| assertThrows("lf.format(['a','b',3])", TypeError, "Iterable yielded 3 which is not a string"); |
| assertThrows("lf.format(sparse)", TypeError, "Iterable yielded undefined which is not a string"); |
| // Test iterable of all String |
| let iterable_of_strings = { |
| return {done: false, value: String(this.count)}; |
| assertDoesNotThrow(() => lf.format(iterable_of_strings)); |
| // Test iterable of none String throw TypeError |
| let iterable_of_strings_and_number = { |
| return {done:false, value: 3}; |
| return {done: false, value: String(this.count)}; |
| assertThrows("lf.format(iterable_of_strings_and_number)", |
| TypeError, "Iterable yielded 3 which is not a string"); |
| assertEquals(3, iterable_of_strings_and_number.count); |