-
-
Notifications
You must be signed in to change notification settings - Fork 832
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8d8cff2
commit 77c32ea
Showing
4 changed files
with
225 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
package { | ||
import flash.display.Sprite; | ||
public class Test extends Sprite { } | ||
} | ||
|
||
import flash.text.engine.GroupElement; | ||
import flash.text.engine.TextElement; | ||
import flash.text.engine.ContentElement; | ||
|
||
function createGroup() { | ||
var vector = new Vector.<ContentElement>() | ||
vector.push(new TextElement("aaaaa")) | ||
vector.push(new TextElement("bbbbb")) | ||
vector.push(new TextElement("ccccc")) | ||
return new GroupElement(vector); | ||
} | ||
|
||
trace("/// replaceElements(0, 0, null)") | ||
var group = createGroup(); | ||
trace("result: " + group.replaceElements(0, 0, null)); | ||
for (var i = 0; i < group.elementCount; i++) { | ||
trace(i + " "+ group.getElementAt(i).text); | ||
} | ||
|
||
trace("/// replaceElements(50, 50, null)") | ||
var group = createGroup(); | ||
trace("result: " + group.replaceElements(50, 50, null)); | ||
for (var i = 0; i < group.elementCount; i++) { | ||
trace(i + " "+ group.getElementAt(i).text); | ||
} | ||
|
||
trace("/// replaceElements(0, 1, null)") | ||
var group = createGroup(); | ||
trace("result: " + group.replaceElements(0, 1, null)); | ||
for (var i = 0; i < group.elementCount; i++) { | ||
trace(i + " "+ group.getElementAt(i).text); | ||
} | ||
|
||
trace("/// replaceElements(0, 3, null)") | ||
var group = createGroup(); | ||
trace("result: " + group.replaceElements(0, 3, null)); | ||
for (var i = 0; i < group.elementCount; i++) { | ||
trace(i + " "+ group.getElementAt(i).text); | ||
} | ||
|
||
/* | ||
trace("/// replaceElements(3, 0, null)") | ||
var group = createGroup(); | ||
trace("result: " + group.replaceElements(3, 0, null)); | ||
for (var i = 0; i < group.elementCount; i++) { | ||
trace(i + " " + group.getElementAt(i)); | ||
} | ||
*/ | ||
|
||
trace("/// replaceElements(1, 1, replacement)") | ||
var group = createGroup(); | ||
var replacement = new Vector.<ContentElement>; | ||
replacement.push(new TextElement("foobar")); | ||
trace("result: " + group.replaceElements(1, 1, replacement)); | ||
for (var i = 0; i < group.elementCount; i++) { | ||
trace(i + " "+ group.getElementAt(i).text); | ||
} | ||
|
||
trace("/// replaceElements(1, 2, replacement)") | ||
var group = createGroup(); | ||
var replacement = new Vector.<ContentElement>; | ||
replacement.push(new TextElement("foobar")); | ||
trace("result: " + group.replaceElements(1, 2, replacement)); | ||
for (var i = 0; i < group.elementCount; i++) { | ||
trace(i + " "+ group.getElementAt(i).text); | ||
} | ||
|
||
trace("/// replaceElements(3, 3, replacement)") | ||
var group = createGroup(); | ||
var replacement = new Vector.<ContentElement>; | ||
replacement.push(new TextElement("foobar")); | ||
trace("result: " + group.replaceElements(3, 3, replacement)); | ||
for (var i = 0; i < group.elementCount; i++) { | ||
trace(i + " "+ group.getElementAt(i).text); | ||
} | ||
|
||
trace("/// replaceElements(1, 1, replacements)") | ||
var group = createGroup(); | ||
var replacements = new Vector.<ContentElement>(); | ||
replacements.push(new TextElement("11111")); | ||
replacements.push(new TextElement("22222")); | ||
trace("result: " + group.replaceElements(1, 1, replacements)); | ||
for (var i = 0; i < group.elementCount; i++) { | ||
trace(i + " "+ group.getElementAt(i).text); | ||
} | ||
|
||
trace("/// replaceElements(1, 2, replacements)") | ||
var group = createGroup(); | ||
var replacements = new Vector.<ContentElement>(); | ||
replacements.push(new TextElement("11111")); | ||
replacements.push(new TextElement("22222")); | ||
trace("result: " + group.replaceElements(1, 2, replacements)); | ||
for (var i = 0; i < group.elementCount; i++) { | ||
trace(i + " "+ group.getElementAt(i).text); | ||
} | ||
|
||
trace("/// splitTextElement(1, 2)"); | ||
var group = createGroup(); | ||
trace("result: " + group.splitTextElement(1, 2).text); | ||
for (var i = 0; i < group.elementCount; i++) { | ||
trace(i + " "+ group.getElementAt(i).text); | ||
} | ||
|
||
trace("/// replaceElements (begin index out-of-bounds)"); | ||
try { | ||
var group = createGroup(); | ||
group.replaceElements(42, 43, null); | ||
} catch (e) { | ||
trace(e) | ||
} | ||
|
||
trace("/// replaceElements (end index out-of-bounds)") | ||
try { | ||
var group = createGroup(); | ||
var replacement = new Vector.<ContentElement>; | ||
replacement.push(new TextElement("foobar")); | ||
replacement.push(new TextElement("hello world")); | ||
group.replaceElements(3, 4, replacement); | ||
} catch (e) { | ||
trace(e); | ||
} | ||
|
||
trace("/// getElementAt (out-of-bounds)"); | ||
try { | ||
var group = createGroup(); | ||
group.getElementAt(42); | ||
} catch (e) { | ||
trace(e) | ||
} | ||
|
||
trace("/// splitTextElement (element index out-of-bounds)"); | ||
try { | ||
var group = createGroup(); | ||
group.splitTextElement(42, 0); | ||
} catch (e) { | ||
trace(e) | ||
} | ||
|
||
trace("/// splitTextElement (text index out-of-bounds)"); | ||
try { | ||
var group = createGroup(); | ||
group.splitTextElement(0, 42); | ||
} catch (e) { | ||
trace(e) | ||
} | ||
|
||
trace("/// splitTextElement (not TextElement)"); | ||
var vector = new Vector.<ContentElement>() | ||
vector.push(new GroupElement()) | ||
var group = new GroupElement(vector); | ||
try { | ||
group.splitTextElement(0, 1); | ||
} catch (e) { | ||
trace(e); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/// replaceElements(0, 0, null) | ||
result: null | ||
0 aaaaa | ||
1 bbbbb | ||
2 ccccc | ||
/// replaceElements(50, 50, null) | ||
result: null | ||
0 aaaaa | ||
1 bbbbb | ||
2 ccccc | ||
/// replaceElements(0, 1, null) | ||
result: [object TextElement] | ||
0 bbbbb | ||
1 ccccc | ||
/// replaceElements(0, 3, null) | ||
result: [object TextElement],[object TextElement],[object TextElement] | ||
/// replaceElements(1, 1, replacement) | ||
result: | ||
0 aaaaa | ||
1 foobar | ||
2 bbbbb | ||
3 ccccc | ||
/// replaceElements(1, 2, replacement) | ||
result: [object TextElement] | ||
0 aaaaa | ||
1 foobar | ||
2 ccccc | ||
/// replaceElements(3, 3, replacement) | ||
result: | ||
0 aaaaa | ||
1 bbbbb | ||
2 ccccc | ||
3 foobar | ||
/// replaceElements(1, 1, replacements) | ||
result: | ||
0 aaaaa | ||
1 11111 | ||
2 22222 | ||
3 bbbbb | ||
4 ccccc | ||
/// replaceElements(1, 2, replacements) | ||
result: [object TextElement] | ||
0 aaaaa | ||
1 11111 | ||
2 22222 | ||
3 ccccc | ||
/// splitTextElement(1, 2) | ||
result: bbb | ||
0 aaaaa | ||
1 bb | ||
2 bbb | ||
3 ccccc | ||
/// replaceElements (begin index out-of-bounds) | ||
RangeError: Error #2006: The supplied index is out of bounds. | ||
/// replaceElements (end index out-of-bounds) | ||
RangeError: Error #2006: The supplied index is out of bounds. | ||
/// getElementAt (out-of-bounds) | ||
RangeError: Error #2006: The supplied index is out of bounds. | ||
/// splitTextElement (element index out-of-bounds) | ||
RangeError: Error #2006: The supplied index is out of bounds. | ||
/// splitTextElement (text index out-of-bounds) | ||
RangeError: Error #2006: The supplied index is out of bounds. | ||
/// splitTextElement (not TextElement) | ||
ArgumentError: Error #2004: One of the parameters is invalid. |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
num_frames = 1 |